SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Checking for an active popup blocker

    Does anyone know if there is a way to check for an active popup window blocker?

    I understand the need for a blocker, but I wished there was a way the blocker would work as if Javascript was turned off.

    For example, in a photo gallery a link to an enlargement:

    Code:
    <a href="link_to_picture" title="name" onclick="opnWin(this,width,height,this.title);return false;">[thumbnail]</a>
    If Javascript is turned off, the enl. picture can still be viewed since the link can be followed. But if JS is turned on and a blocker is active, nothing happens at all.

    Would it not be better, if the browser would still follow the link, but ignore the Javascript? It does have access to the script after all.

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need a function that tries to open the window, checks if the window is open, then returns true or false depending.

    PHP Code:
    function opnWin(url){
        
    window["tempWin"] = window.open(url,"newWin","width=500,height=500");
        if (
    tempWin) {
            return 
    false;
        } else {
            return 
    true;
        }


  3. #3
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    yes, that would make sense, but I think the IE popup blocker if set to "High" blocks the popup and ignores the rest of the Javascript, so the function will always return true if JS is turned on.

  4. #4
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    I meant, the function will always return false because IE blocks the popup AFTER the window is opened.

  5. #5
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use a try/catch and follow the link in the catch


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
  •