SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict gthorley's Avatar
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am having some problems with a script that loads popups. I understand on some machines it fails to work. The suggestion has been made that it is a timing problem ie: the file is trying to load before the window loads.

    This is the function


    function win(fileName) {
    myFloater = window.open('','myWindow','scrollbars=no,status=no,width=550,height=500,top=15,left=200')
    myFloater.location.href = fileName;
    }

    and a sample call

    <A HREF="javascript:win('monoprints/geese.html')"><img src="monoprints/S_geese.jpg" width="252" height="177" border="0"></a>

    Question how can I put a timeout of say 1000 to ensure the popup window is loaded before the "geese.html" page tries to enter it. I tried something like this to amend the function but it didn't work. The popup window was created but the geese.html didn't load in it.

    setTimeout("myFloater.location.href = fileName",1000);

    If anyone could help it would be appreciated.

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Why don't you just specify the page to load in the window.open() call?

    function win(filename) {
    myFloater = window.open(filename,'myWindow','scrollbars=no,status=no,width=550,height=500,top=15,left=200')
    }
    Last edited by Kevin Yank; Feb 25, 2001 at 22:23.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Addict gthorley's Avatar
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you saying that I just need to amend my function and leave my links as they are?

    I tried replacing the function I had with the one you gave and when the image is clicked nothing happens?

    P.S. There are 6-8 images on the page which need to work off this function
    Last edited by gthorley; Feb 24, 2001 at 12:45.

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, all you should need to change is the function. All 6-8 images should be able to use it without any trouble at all.

    Are any JavaScript errors occuring when you click the link (watch for the yellow exclamation mark in the bottom-left corner of the MSIE window)?

    Can you point me to an example page where this is failing to work?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  5. #5
    SitePoint Addict gthorley's Avatar
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I found the problem filename was defined as fileName.
    Seems to be working fine now.
    Thanks for the help.
    Last edited by gthorley; Feb 25, 2001 at 21:05.

  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Good to hear, Graham! Sorry about the typo; I've corrected it above for the benefit of future readers.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Addict gthorley's Avatar
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kyank I got the original function from somewhere don't know where but is it good/better syntax to use "fileName" rather than "filename" to ensure there can be know mistakes from using a word that could appear in other context.

  8. #8
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Neither method is better or worse than the other. Use whichever you prefer.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


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
  •