Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12094

Re: setTimeout and onclick

Message-ID <2263175.FRqVoOGUtd@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-02-23 14:58 +0100
Subject Re: setTimeout and onclick
Newsgroups comp.lang.javascript
References <bq9ck7l21j5j0t5tfmiegdlevuopg8dfh9@4ax.com>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Bootleg Bart wrote:

> onclick works and changes the self location in IE and Chrome. A new
> window is also opened with the href="javascript:v6" in IE and Chrome.
> 
> FireFox - onclick changes the self.location but doesn't open a new
> window.What am I doing wrong? Thanks.

_Firefox_

> <area coords="159, 110, 234, 127"

RTFM.  There are not supposed to be spaces in that attribute value.  Some 
parsers are more forgiving than others.

> 
href="javascript:v6('securitydetails.htm','_blank','scrollbars=yes,resizable=yes,width=780,height=690,top=0,left=0')"

Please read the FAQ on `javascript:' URIs.

<http://jibbering.com/faq/>

> onclick="setTimeout(window.location.href='360v6.htm', 500)"
> shape="rect" />

This assigns '360v6.htm' to window.location.href, which causes navigation 
*before* setTimeout() is called (as the assignment is the expression that 
makes up the argument).  If you are lucky, setTimeout() can be called; if 
not, a TypeError exception will be thrown because the object previously 
referred to by `setTimeout' has already been destructed because of 
navigation.

In general, you are looking for

  window.setTimeout(function () { window.location = '360v6.htm'; }, 500);

although that does not make much sense here.  Why do you want to slow down 
the user?


PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

setTimeout and onclick Bootleg Bart <jknmp@axcop.org> - 2012-02-23 05:55 -0600
  Re: setTimeout and onclick Bootleg Bart <jknmp@axcop.org> - 2012-02-23 06:57 -0600
    Re: setTimeout and onclick Bootleg Bart <jknmp@axcop.org> - 2012-02-23 07:42 -0600
  Re: setTimeout and onclick Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-23 14:58 +0100
    Re: setTimeout and onclick Bootleg Bart <jknmp@axcop.org> - 2012-02-23 08:48 -0600
      Re: setTimeout and onclick Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-23 15:59 +0100
    Re: setTimeout and onclick Bootleg Bart <jknmp@axcop.org> - 2012-02-23 08:51 -0600
      Re: setTimeout and onclick Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-23 15:55 +0100

csiph-web