Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript only working when Refreshed

    I have a simple window.open script that won't work when the page is initially pulled up, but works when the page is refreshed. Is this an environment issue or is there some other script that may work for this?

    <SCRIPT language="JavaScript">
    window.open("http://www.cnn.com","Zippy","width=420,height=375,resizable=yes,scrollbars=yes");
    </SCRIPT>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps there are other scripts on the page which are erroring out and causing that script to not be executed.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It seems if that was the case then it wouldn't work at all, but it does work when the page is refreshed.

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree with Vladdy's response to your question which was also posted here....
    It doesn't work for me no matter what....
    Must be the popup blocker....

  • #5
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have also tried placing this in the <head>

    <SCRIPT language="JavaScript">
    function init() {
    logpop=window.open("http://www.cnn.com","Zippy","width=420,height=375,resizable=yes,scrollbars=yes");
    logpop.focus();
    }
    <SCRIPT>

    and placing this in the <body> tag:

    onload="init()"

    When the page first loads I get an error stating that logpop is null or not an object. This error is being caused by logpop.focus(); because the window did not open. Then when I refresh the page, it works fine.

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the 1st script works fine in my IE6+ browser and its quite annoying to.

  • #7
    New Coder
    Join Date
    Jun 2004
    Location
    Coventry, UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error in Definition

    Quote Originally Posted by blackw0lf
    logpop=window.open("http://www.cnn.com","Zippy","width=420,height=375,resizable=yes,scrollbars=yes");
    In this line, with the logpop=window.open, replace it with logpop = window.open.

    If this fixs it it means that log pop was not being declared properly. As for the fact it only works when refreshed ive no clue...
    LOTS8

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by lordofthesword8
    In this line, with the logpop=window.open, replace it with logpop = window.open.

    If this fixs it it means that log pop was not being declared properly. As for the fact it only works when refreshed ive no clue...
    The space doesn't matter though it's more readable if you put one.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #9
    New Coder
    Join Date
    Jun 2004
    Location
    Coventry, UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Really?

    Thanks for that I always thought it was part of the syntax.
    LOTS8


  •  

    Posting Permissions

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