Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick event in NN4.7

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
I have this code that works just fine in IE5 but I want it also to work in NN4.7. It seems that NN4.7 doesn't react to the 'onclick'-event. Is there another way to make it work?

Code:
<input type=&quot;image&quot; src=&quot;/jpg/button.jpg&quot; onclick=&quot;document.formname.variable.value='1';parent.frames[2].location.reload()&quot; border=&quot;0&quot;>

Thnx, Sven :cool:
 
hmm netscape definitely responds to onclick so it is more likely that the problem is the way in which you reference the form. If you try onclick=&quot;alert('hi');&quot; this will work fine in NS4.

Is your form in a DIV? When referencing forms in NS4 and they are in a div you have to use

document.divID.document.formname.elementname

this will mean you will need to detect which browser the user has and have different code for different browsers.

Use:

var ns4 = (document.layers)? true:false;
var dom = (document.getElementById)? true:false;

to set boolean variables for NS4 browser and DOM browsers (IE5+ and NS6+). you can use document.all to test for IE4 as well if you want to be really thorough.

If you still have problems post your source code and maybe the problem will be clearer

hope this helps

rob
 
sfenx, you've made a major mistake.
Remember this: <input type=&quot;image&quot;> acts only as submit button of a form.
Those additional actions you added to it &quot;confuse&quot; NN4.7.

The solution is very simple - change it to a good old image link:

<a href=&quot;#&quot; onclick=&quot;document.formname.variable.value='1'; parent.frames[2].location.reload()&quot;><img src=&quot;/jpg/button.jpg&quot; width=&quot;&quot; height=&quot;&quot; border=&quot;0&quot;></a>

This works in all browsers.
 
Starway, I've tryed your option and it didn't get it to work. Perhaps you can help me with the code I put next?
Rob, I do use a DIV around my form. Here's my piece of code:
PS: there's some ASP in it.

Code:
<DIV align=&quot;right&quot; style=&quot;position:absolute; right:25px; top:9px; z-index:2&quot;>
  	<% strSQL = &quot;select * from URL where URL_NAAM = 'frameboven'&quot;
	set rsTMP = svenconn.execute(strSQL) %>
	<FORM name=&quot;TaalForm&quot; action=<% response.write rsTMP(&quot;URL_LOCATIE&quot;) %> method=&quot;post&quot; target=&quot;frameboven&quot;>
	<% rsTMP.close %>
	<input type=&quot;hidden&quot; name=&quot;taalnr&quot;>

	<DIV align=&quot;right&quot;>
	<% if taalnr = &quot;2&quot; then %>
		<input type=&quot;image&quot; src=&quot;/jpg/NLButton.jpg&quot; onclick=&quot;document.TaalForm.taalnr.value='1';parent.frames[2].location.reload()&quot; border=&quot;0&quot;>
	<% else %>
		<input type=&quot;image&quot; src=&quot;/jpg/FRButton.jpg&quot; onclick=&quot;document.TaalForm.taalnr.value='2';parent.frames[2].location.reload()&quot; border=&quot;0&quot;>
	<% end if %>
	</div>
	<% response.cookies(&quot;taalnr&quot;) = taalnr %>
	</form>
</div>
The reason why I used a second DIV around the <input type=&quot;image&quot;>-tage is that without it, in NN4 (only) the image is aligned to the left.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top