Closed Thread Icon

Topic awaiting preservation: Anchor Tag - onclick event w/no parent window refresh (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=24037" title="Pages that link to Topic awaiting preservation: Anchor Tag - onclick event w/no parent window refresh (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Anchor Tag - onclick event w/no parent window refresh <span class="small">(Page 1 of 1)</span>\

 
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-14-2004 19:01

Hello,

This onclick event causes the containing page to refresh even though the return value is 0, and the jscript is only suppose to launch a new window. How do I eliminate the main page from refreshing?

<a href="#" onclick="promoteevent(); return 0;">- Click Here For More Information -</a>

Karl

kuckus
Paranoid (IV) Mad Librarian

From: Berlin
Insane since: Dec 2001

posted posted 11-14-2004 19:20

Give this a try:

code:
<a href="javascript:void(0);" onclick="promoteevent();">- Click Here For More Information -</a>



Or:

code:
<a href="javascript:promoteevent();">- Click Here For More Information -</a>

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-14-2004 20:08

Hey that works! For some reason, I was under the impression that "return 0;" was sufficient in the onclick event or that you could do something like "return(promoteevent()); where promoteevent() always returned 0.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-14-2004 20:10

Return false, not 0.


 

liorean
Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 11-14-2004 20:18

For compatibility the check for the return value to cancel a default action is strict. It must be the false value and nothing else. The reason is that the default value of a function return is undefined, which autocasts to false, and thus they couldn't allow autocasting since that would mean any function that doesn't return a value cancels the default event.

--
var Liorean = {
prototype: ProgrammingTheoryGuru.prototype,
abode: "http://codingforums.com/",
profile: "http://codingforums.com/member.php?u=5798"};

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 11-14-2004 20:44

doh! Thanks for the explanation liorean.

« BackwardsOnwards »

Show Forum Drop Down Menu