SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: window.open

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    East of Ottawa, ON
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.open

    Is this accessible?

    I did add a note indicating that it opens in a new window.

    "Please note: this link will open the page in a new browser window."

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That depends on how you invoke window.open().

    This will be accessible,
    Code HTML4Strict:
    <a href="popup.html" onclick="return !!window.open(this.href,'popup')">link text</a>

    This won't,
    Code HTML4Strict:
    <a href="javascript:window.open('popup.html','popup')">link text</a>
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    East of Ottawa, ON
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using jquery click function for this.

    So if I disable javascript the page will open in the same window.

  4. #4
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    East of Ottawa, ON
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    $('#accordion li a').click( function() {
    		window.open( $(this).attr('href'), "foo", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=828,height=648,top=25,left=60");
    		return false;
        }).attr("title", "Please note: this link will open the page in a new browser window.");;
     
     });

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geargolum View Post
    So if I disable javascript the page will open in the same window.
    That should take care of the accessibility issue, although there may or may not be a usability issue with forcing a pop-up window to begin with.

    Also, the text that informs the user that the link opens in a new window should be created with JavaScript, since the function itself requires JavaScript. And it shouldn't be in a title attribute only, since there is no guarantee that a user will see that. Especially those of us who navigate by keyboard rarely see those advisory titles.
    Birnam wood is come to Dunsinane

  6. #6
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    I would also note that you should have some form of fail-safe mechanism in place to check if popup's are blocked, the ideal scenario would be that if people have pop-up messages enabled then it would use your unobtrusive script to make that happen, but if pop-up's are blocked (possibly test through JavaScript?) or if scripting is not enabled, it will simply navigate to the URL. I have seen websites redirect when a pop-up fails so it must be possible


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •