Links Won't Open In New Window in IE

Discussion in 'Javascript' started by dev/null, Jul 1, 2009.

  1. dev/null

    dev/null Guest

    I'm experiencing a problem with IE7 and IE8. Links to external pages
    won't open in a new window, but links to internal pages work fine.
    For example

    <a href="#" onClick="window.open('http://en.wikipedia.org/wiki/
    SSL_Certificate','SSL
    Certificate','scrollbars=yes,width=500,height=500');" >follow this
    link</a>

    works fine in Firefox 3.5, but it simply redirects back to the same
    page in IE. However, trying to open a new window to a page that is on
    the same directory level as the page which has the link works fine;
    <a href="#" onClick="window.open
    ('test.php','test','scrollbars=yes,width=500,height=500');" >follow
    this link</a> opens in a new window without a problem.

    I have firebug 1.4 installed on Firefox, and I'm not getting any
    errors when I click on the link. Any suggestions?
    dev/null, Jul 1, 2009
    #1
    1. Advertising

  2. dev/null wrote:
    > I'm experiencing a problem with IE7 and IE8. Links to external pages
    > won't open in a new window, but links to internal pages work fine.
    > For example
    >
    > <a href="#" onClick="window.open('http://en.wikipedia.org/wiki/
    > SSL_Certificate','SSL
    > Certificate','scrollbars=yes,width=500,height=500');" >follow this
    > link</a>
    >
    > works fine in Firefox 3.5, but it simply redirects back to the same
    > page in IE. However, trying to open a new window to a page that is on
    > the same directory level as the page which has the link works fine;
    > <a href="#" onClick="window.open
    > ('test.php','test','scrollbars=yes,width=500,height=500');" >follow
    > this link</a> opens in a new window without a problem.
    >
    > I have firebug 1.4 installed on Firefox, and I'm not getting any
    > errors when I click on the link. Any suggestions?


    Isn't this a new browser anti-popup security thing?
    The Natural Philosopher, Jul 1, 2009
    #2
    1. Advertising

  3. dev/null

    BootNic Guest

    On Wed, 1 Jul 2009 13:21:17 -0700 (PDT)
    "dev/null" <> wrote:

    > I'm experiencing a problem with IE7 and IE8. Links to external
    > pages won't open in a new window, but links to internal pages
    > work fine. For example
    >
    > <a href="#"
    > onClick="window.open('http://en.wikipedia.org/wiki/
    > SSL_Certificate','SSL
    > Certificate','scrollbars=yes,width=500,height=500');" >follow
    > this link</a>


    The window name in the above example appears to have some sort of
    white space, perhaps a space. “SSL Certificate†Remove or replace the
    white space.

    <a href="http://www.example.com/"
    onclick="window.open(this.href,'popwin');return false;">example</a>

    [snip]

    > <a href="#" onClick="window.open
    > ('test.php','test','scrollbars=yes,width=500,height=500');" >follow
    > this link</a> opens in a new window without a problem.


    This above window name does not have any white space.

    [snip]



    --
    BootNic Wed Jul 1, 2009 06:06 pm
    When I was younger, I could remember anything, whether it had
    happened or not.
    *Mark Twain*

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.11 (GNU/Linux)

    iEYEARECAAYFAkpL3dsACgkQmo2774GZ7qmIlgCeKwY6hkFLxbOvhXvLkcshV73R
    2G4AoNO23vhGXVPf7jLtr5fBaM/N+xb7
    =dkZP
    -----END PGP SIGNATURE-----
    BootNic, Jul 1, 2009
    #3
  4. dev/null

    Tim Down Guest

    On Jul 1, 9:21 pm, "dev/null" <> wrote:
    > I'm experiencing a problem with IE7 and IE8.  Links to external pages
    > won't open in a new window, but links to internal pages work fine.
    > For example
    >
    > <a href="#" onClick="window.open('http://en.wikipedia.org/wiki/
    > SSL_Certificate','SSL
    > Certificate','scrollbars=yes,width=500,height=500');" >follow this
    > link</a>
    >
    > works fine in Firefox 3.5, but it simply redirects back to the same
    > page in IE.  However, trying to open a new window to a page that is on
    > the same directory level as the page which has the link works fine;
    > <a href="#" onClick="window.open
    > ('test.php','test','scrollbars=yes,width=500,height=500');" >follow
    > this link</a> opens in a  new window without a problem.
    >
    > I have firebug 1.4 installed on Firefox, and I'm not getting any
    > errors when I click on the link.  Any suggestions?



    Why are you trying to do this with JavaScript? Why not simply use the
    target attribute of the <a> element?

    <a href="test.php" target="_blank">test page</a>

    Tim
    Tim Down, Jul 2, 2009
    #4
  5. Tim Down wrote:
    > On Jul 1, 9:21 pm, "dev/null" <> wrote:
    >> I'm experiencing a problem with IE7 and IE8. Links to external pages
    >> won't open in a new window, but links to internal pages work fine.
    >> For example
    >>
    >> <a href="#" onClick="window.open('http://en.wikipedia.org/wiki/
    >> SSL_Certificate','SSL
    >> Certificate','scrollbars=yes,width=500,height=500');" >follow this
    >> link</a>
    >>
    >> works fine in Firefox 3.5, but it simply redirects back to the same
    >> page in IE. [...] Any suggestions?

    >
    > Why are you trying to do this with JavaScript? Why not simply use the
    > target attribute of the <a> element?
    >
    > <a href="test.php" target="_blank">test page</a>


    (target="_blank" is bad, use a unique window name instead.)

    A plain link does not allow for trying to set the width and height of the
    new window (if that); window.open() does. Both can be subject to popup
    blockers.

    However, the link above certainly is ill-advised (the whitespace in the
    window name aside): nothing works without scripting; even worse, the UA
    might as well scroll to the top of the document (`#' denotes a
    same-document URI-reference) regardless of whether scripting works or not.
    Much better (remove newline within the attribute value):

    <a href="http://en.wikipedia.org/wiki/SSL_Certificate"
    target="wikipedia"
    title="More about SSL certificates at Wikipedia"
    onclick="return !window.open(this.href, this.target,
    'width=500,height=500,resizable,scrollbars');"
    >SSL Certificate</a>



    PointedEars
    Thomas 'PointedEars' Lahn, Jul 2, 2009
    #5
  6. dev/null

    Tim Down Guest

    On Jul 2, 10:40 am, Thomas 'PointedEars' Lahn <>
    wrote:
    > (target="_blank" is bad, use a unique window name instead.)


    Why is target="_blank" worse than a unique window name? Because it is
    irritating for the user to always get a new window regardless of
    whether one was already open? Are links using target="_blank" more
    likely to be blocked by pop-up blockers than ones that use a normal
    window name instead? My knowledge on this is not up to date.

    Tim
    Tim Down, Jul 2, 2009
    #6
  7. Tim Down wrote:
    > Thomas 'PointedEars' Lahn wrote:
    >> (target="_blank" is bad, use a unique window name instead.)

    >
    > Why is target="_blank" worse than a unique window name? Because it is
    > irritating for the user to always get a new window regardless of
    > whether one was already open?


    Exactly. In addition, new windows/tabs cost more memory that is not
    always/immediately freed completely (especially on older Windozes).

    > Are links using target="_blank" more likely to be blocked by pop-up
    > blockers than ones that use a normal window name instead?


    Probably, whereas "blocked" includes "re-routed" (for the lack of a better
    term).

    > My knowledge on this is not up to date.


    Sorry, I cannot provide test results or figures. There was much too little
    incentive for that.

    However, to avoid opening new windows (or tabs, but tabbed browsing wasn't
    there yet) has also been recommended repeatedly by Jakob Nielsen, arguably
    then and now the leading expert on usability. Cf.:

    "The Top Ten Web Design Mistakes of 1999"
    <http://www.useit.com/alertbox/990530.html>

    "Top Ten Web Design Mistakes of 2005"
    <http://www.useit.com/alertbox/designmistakes.html>

    Incidentally, those and

    "Top Ten Guidelines for Homepage Usability" (2002)
    <http://www.useit.com/alertbox/20020512.html>

    also cover what I implicitly recommended about the link caption.
    Never ever use "follow this link" or "link" for that.


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Jul 2, 2009
    #7
  8. dev/null

    Tim Down Guest

    On Jul 2, 5:57 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > Tim Down wrote:
    > > My knowledge on this is not up to date.

    >
    > Sorry, I cannot provide test results or figures.  There was much too little
    > incentive for that.
    >
    > However, to avoid opening new windows (or tabs, but tabbed browsing wasn't
    > there yet) has also been recommended repeatedly by Jakob Nielsen, arguably
    > then and now the leading expert on usability.  Cf.:
    >
    > "The Top Ten Web Design Mistakes of 1999"
    > <http://www.useit.com/alertbox/990530.html>
    >
    > "Top Ten Web Design Mistakes of 2005"
    > <http://www.useit.com/alertbox/designmistakes.html>
    >
    > Incidentally, those and
    >
    > "Top Ten Guidelines for Homepage Usability" (2002)
    > <http://www.useit.com/alertbox/20020512.html>
    >
    > also cover what I implicitly recommended about the link caption.
    > Never ever use "follow this link" or "link" for that.


    I'm aware that opening links in a new window has been frowned upon
    with good reason for some time and have read those articles, just not
    the specifics of why target="_blank" was worse. I recall also that
    using a window name other than "_blank" had the disadvantage of not
    focussing the target window in some browsers (can't remember which),
    meaning that clicking a link would have no visible effect if the
    target window was obscured.

    Tim
    Tim Down, Jul 2, 2009
    #8
  9. dev/null

    David Mark Guest

    On Jul 2, 5:53 pm, Tim Down <> wrote:
    > On Jul 2, 5:57 pm, Thomas 'PointedEars' Lahn <>
    > wrote:
    >
    >
    >
    > > Tim Down wrote:
    > > > My knowledge on this is not up to date.

    >
    > > Sorry, I cannot provide test results or figures.  There was much too little
    > > incentive for that.

    >
    > > However, to avoid opening new windows (or tabs, but tabbed browsing wasn't
    > > there yet) has also been recommended repeatedly by Jakob Nielsen, arguably
    > > then and now the leading expert on usability.  Cf.:

    >
    > > "The Top Ten Web Design Mistakes of 1999"
    > > <http://www.useit.com/alertbox/990530.html>

    >
    > > "Top Ten Web Design Mistakes of 2005"
    > > <http://www.useit.com/alertbox/designmistakes.html>

    >
    > > Incidentally, those and

    >
    > > "Top Ten Guidelines for Homepage Usability" (2002)
    > > <http://www.useit.com/alertbox/20020512.html>

    >
    > > also cover what I implicitly recommended about the link caption.
    > > Never ever use "follow this link" or "link" for that.

    >
    > I'm aware that opening links in a new window has been frowned upon
    > with good reason for some time and have read those articles, just not
    > the specifics of why target="_blank" was worse. I recall also that
    > using a window name other than "_blank" had the disadvantage of not
    > focussing the target window in some browsers (can't remember which),
    > meaning that clicking a link would have no visible effect if the
    > target window was obscured.


    That is the case for a named popup window that exists and has already
    been obscured (clearly impossible for _blank.) Can be worked around
    with scripting, but best to avoid popups entirely.
    David Mark, Jul 3, 2009
    #9
  10. dev/null

    David Mark Guest

    On Jul 2, 12:57 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > Tim Down wrote:
    > > Thomas 'PointedEars' Lahn wrote:
    > >> (target="_blank" is bad, use a unique window name instead.)

    >
    > > Why is target="_blank" worse than a unique window name? Because it is
    > > irritating for the user to always get a new window regardless of
    > > whether one was already open?

    >
    > Exactly.  In addition, new windows/tabs cost more memory that is not
    > always/immediately freed completely (especially on older Windozes).
    >
    > > Are links using target="_blank" more likely to be blocked by pop-up
    > > blockers than ones that use a normal window name instead?

    >
    > Probably, whereas "blocked" includes "re-routed" (for the lack of a better
    > term).
    >
    > > My knowledge on this is not up to date.

    >
    > Sorry, I cannot provide test results or figures.  There was much too little
    > incentive for that.
    >
    > However, to avoid opening new windows (or tabs, but tabbed browsing wasn't
    > there yet) has also been recommended repeatedly by Jakob Nielsen, arguably
    > then and now the leading expert on usability.  Cf.:
    >
    > "The Top Ten Web Design Mistakes of 1999"
    > <http://www.useit.com/alertbox/990530.html>
    >
    > "Top Ten Web Design Mistakes of 2005"
    > <http://www.useit.com/alertbox/designmistakes.html>
    >


    I hope he's learned something about Web design since 2005. I haven't
    looked at the actual content yet, but the markup is awful.

    [snip]
    David Mark, Jul 3, 2009
    #10
  11. David Mark wrote:
    > Thomas 'PointedEars' Lahn wrote:
    >> "Top Ten Web Design Mistakes of 2005"
    >> <http://www.useit.com/alertbox/designmistakes.html>

    >
    > I hope he's learned something about Web design since 2005. I haven't
    > looked at the actual content yet, but the markup is awful.


    Probably he has not written the markup as it is. AFAIK, he can be
    considered an authority on usability, but not on HTML (or other markup
    languages). I would consider that a good thing, though, because a
    different perspective often helps to see what really is important.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
    Thomas 'PointedEars' Lahn, Jul 3, 2009
    #11
  12. dev/null

    David Mark Guest

    On Jul 2, 9:52 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > David Mark wrote:
    > > Thomas 'PointedEars' Lahn wrote:
    > >> "Top Ten Web Design Mistakes of 2005"
    > >> <http://www.useit.com/alertbox/designmistakes.html>

    >
    > > I hope he's learned something about Web design since 2005.  I haven't
    > > looked at the actual content yet, but the markup is awful.

    >
    > Probably he has not written the markup as it is.  AFAIK, he can be
    > considered an authority on usability, but not on HTML (or other markup
    > languages).  I would consider that a good thing, though, because a
    > different perspective often helps to see what really is important.
    >


    I didn't say his article wasn't a good thing. Largely, it was. There
    was at least one mistake, but I'll assume he's figured it out since.
    David Mark, Jul 3, 2009
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gordon
    Replies:
    3
    Views:
    286
    Steven Burn
    Apr 16, 2004
  2. PC HUA
    Replies:
    2
    Views:
    390
    PC HUA
    May 19, 2004
  3. jdapro
    Replies:
    1
    Views:
    131
    kaeli
    Mar 22, 2005
  4. Replies:
    2
    Views:
    324
  5. Replies:
    1
    Views:
    223
Loading...

Share This Page