...

View Full Version : Links that jump around



Boot Weasel
07-16-2003, 12:16 AM
I had an earlier question answered about how to change two iframes with one click of a link. Now, my iframes respond when I invoke them, but with this code I'm using ---

<a onclick="window.open('DrMenu.htm','menu') ; window.open('BioStaff.htm','contents')" href="#">One Link to Change Them ALL!!!</a>

clicking the link sends my entire page (not the iframes, but the page they are embedded on) to it's very bottom (like hitting the End button in a Word document). Granted, it's not a tall page and it doesn't have a long way to go, but it is jarring, and I do not want to injure my users.

Why is this happening? If you know how to fix it, would you?

Thanks, everyone.

Have a great mini.

Boot.

Choopernickel
07-16-2003, 01:49 PM
<a onclick="window.open('DrMenu.htm','menu') ; window.open('BioStaff.htm','contents') ; return false;" href="#">One Link to Change Them ALL!!!</ a>


should do ya

Kor
07-16-2003, 01:56 PM
or

<a href="javascript:window.open('DrMenu.htm','menu') ; window.open('BioStaff.htm','contents'); return true">One Link to Change Them ALL!!!</a>

Boot Weasel
07-16-2003, 04:06 PM
Yeah, this worked fine, but if you have time, could you explain exactly what return false/true does?

Choopernickel
07-16-2003, 04:15 PM
When you return false in an event handler <a onclick="return false">), you essentially cancel that event, making it look to the normal execution of the page as though nothing happened.

When you return true in a javascript URL (<a href="javascript:blah();return true;">), essentially you're doing nothing. By default, event handlers return true, unless they cancel themselves during execution (possible, but rarely seen) using event.stopPropogation() or event.returnValue = false; or something along those lines.


The value returned at the end of an event handler is essentially a flag as to whether the page should act as though anything happened outside the script that has already executed.

HTH.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum