SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Pittsburgh, PA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript causing Firefox "loop"

    Greetings all,

    I am currently working on a bit of Javascript code for some popunders. It seems to work fine on just about every browser except Firefox. It seems to cause firefox to reload the page in some kind of a loop. I even tried to disable the popup blocker and it gives me the same result.

    Here is the function that is doing the popunder.

    thanks in advance!

    Code:
    function load_pop_power(){
    
    var randomchoice = Math.floor(Math.random()*(popunder.length));
    var p = 'scrollbars=' + scrollbars[randomchoice] + ',' +
            'resizable=' + resizable[randomchoice] + ',' +
            'toolbar=' + toolbar[randomchoice] + ',' +
            'menubar=' + menubar[randomchoice] + ',' +
            'status=' + status[randomchoice] + ',' +
            'location=' + location[randomchoice] + ',' +
            'left=85,' +
            'top=20,' +
            'height=' + height[randomchoice] + ',' +
            'width=' + width[randomchoice];
    
    var win2=window.open(popunder[randomchoice],"bw",p)
    win2.blur()
    window.focus()
    }

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what event is calling that function?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Pittsburgh, PA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if (one_time==0)
    load_pop_power()
    else
    loadornot()
    loadornot() is not called because the var one_time==0

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you put an alert("hi") after load_pop_power(), does that fire in a loop also?

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Pittsburgh, PA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually I get a syntax error when I try to put in alert("hi")

    I ran the javascript console in firefox and getting the error:

    win2 has no properties on line 81

    which is marked:

    Code:
    var win2=window.open(popunder[randomchoice],"bw",p)
    win2.blur()           //<-- line 81
    window.focus()

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Pittsburgh, PA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If this helps I load this popunder via the following command:

    <SCRIPT language="JavaScript" SRC="popunder.js"></SCRIPT>

  7. #7
    SitePoint Guru
    Join Date
    Feb 2005
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by human39
    actually I get a syntax error when I try to put in alert("hi")

    I ran the javascript console in firefox and getting the error:

    win2 has no properties on line 81

    which is marked:

    Code:
    var win2=window.open(popunder[randomchoice],"bw",p)
    win2.blur()           //<-- line 81
    window.focus()
    I'm no expert on popups, but that leads me to believe that win2.blur executes before window.open finishes. Try setTimeout("win2.blur()", 100) to avoid that error.

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since setting the focus to the current window automatically blurs the old window, you might be able to just delete the blur() line altogether.


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
  •