SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot nikola8's Avatar
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need unblockable pop under java code

    I'm looking for javascript code that will open popuner window with URL (web page in it) when visitor open my site (on load) or on exit.

    I want something that will pass firefox and all other popup blockers.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,604
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    There is nothing that can bypass the blockers as the blockers are specifically designed to block windows opening in those situations.

    The only way to bypass the blockers is to open the new window when your visitor clicks a link.

    The only other way to do it is as a popin within the web page itself.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Zealot nikola8's Avatar
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, how to "open the new window when your visitor clicks a link."

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by nikola8 View Post
    So, how to "open the new window when your visitor clicks a link."
    By attaching a function to the link's onclick event from where you could use window.open using the alwaysLowered setting to put the new window behind the current one.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <a href="www.google.com" target="_blank">LINK</a>
    This will open in a new window.

    EDIT:

    By attaching a function to the link's onclick event from where you could use window.open using the alwaysLowered setting to put the new window behind the current one.
    Unless you want it always behind, in which case Paul's got it right.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,604
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by sd_javascript View Post
    HTML Code:
    <a href="www.google.com" target="_blank">LINK</a>
    This will open in a new window.
    But should not be used because:

    1. target is deprecated and ceased to be a proper part of HTML back in 1997.
    2. Opening a new window is a behaviour and so should be done using JavaScript and not HTML.

    The correct code for such a link (but jumbling the JavaScript with the HTML to make the comparison more obvious - rather than doing it properly with separate files the way you'd do it for a proper web page) is:

    HTML Code:
    <a href="www.google.com" onclick="newwin window.open(this.href);newwin.blur();">LINK</a>
    Of course since blur (and focus) are non-standard for windows it will depend on which browser your visitor is using as to which window will end up on top.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    But should not be used because:

    1. target is deprecated and ceased to be a proper part of HTML back in 1997.
    2. Opening a new window is a behaviour and so should be done using JavaScript and not HTML.

    The correct code for such a link (but jumbling the JavaScript with the HTML to make the comparison more obvious - rather than doing it properly with separate files the way you'd do it for a proper web page) is:

    HTML Code:
    <a href="www.google.com" onclick="newwin window.open(this.href);newwin.blur();">LINK</a>
    Of course since blur (and focus) are non-standard for windows it will depend on which browser your visitor is using as to which window will end up on top.
    OH! Ha, sorry, good to know!! Thanks!


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
  •