SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast Damir Secki's Avatar
    Join Date
    Jul 2001
    Location
    Slovenia, Europe
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help... window.onLoad with FF not working

    Hello...

    I have implemented a swf flash movie clip onto my page.
    I am using onLoad JS function to set some variables in my flash movie and to start playing it.

    Code:
     <SCRIPT LANGUAGE="JavaScript">
     
     window.onload = function(){
       document.swfid.SetVariable("product", "7");
       document.swfid.SetVariable("userID", "377");
       document.swfid.SetVariable("uploaded", 1);
       document.swfid.Play();
     } 
     
     </SCRIPT>
    This code works great on IE but not working at all on FF, unles I refresh the page :S

    Please advise
    Damir Sečki
    PHP (mainly cakePHP)/mySQL/JavaScript (jQuery)/HTML/CSS developer
    BlabberStar.com - Tratsche.de - Petteguless.it

  2. #2
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give the function a name and set window.onload to the function name (without quotes):

    Code:
    function myFunc() {
    // function code
    }
    
    window.onload = myFunc;
    By the way, I have never been able to script any sort of plugin, embed, or applet in Firefox, although they claim it will work.

  3. #3
    SitePoint Enthusiast Damir Secki's Avatar
    Join Date
    Jul 2001
    Location
    Slovenia, Europe
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a.dotty.dot:

    I did as you suggested... but it is stil the same. I have to refresh the windows to make it work. EACH TIME the same.

    But after refresh I can pass the values to my flash movie

    you can check it on http://www.ab-line.si/products/index.php?product=1 so you can see what am I talking about
    Damir Sečki
    PHP (mainly cakePHP)/mySQL/JavaScript (jQuery)/HTML/CSS developer
    BlabberStar.com - Tratsche.de - Petteguless.it

  4. #4
    SitePoint Addict dek's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One of my knee-jerk hacks to problems like this is to delay execution of the problem code, in case something else needs to load.

    Code:
        <SCRIPT LANGUAGE="JavaScript">
        
        window.onload = function() { setTimeout(function(){
          document.swfid.SetVariable("product", "7");
          document.swfid.SetVariable("userID", "377");
          document.swfid.SetVariable("uploaded", 1);
          document.swfid.Play();
        }, 100); }
        
        </SCRIPT>
    for a truly ugly, been-a-long-day-and-can't-be-arsed-to-format-it kinda example.

    You never know - it might even work
    Only dead fish go with the flow

  5. #5
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In other words, you have to load the page twice for it to work? It doesn't work the first time the page loads but does work when you reload it?

  6. #6
    SitePoint Enthusiast Damir Secki's Avatar
    Join Date
    Jul 2001
    Location
    Slovenia, Europe
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by a.dotty.dot
    In other words, you have to load the page twice for it to work? It doesn't work the first time the page loads but does work when you reload it?
    exactly...

    If I access this page trough a link... it doesnt work the first time, but anyother next time it does after refreshing it. check the link to see....

    @dek:

    it could be the delay.... that onload is executed before the flash is actually loaded, but I don't think so...couse every and each time after refreshing it works great... and if that were the case.. it shouldn't worj in IE too
    Damir Sečki
    PHP (mainly cakePHP)/mySQL/JavaScript (jQuery)/HTML/CSS developer
    BlabberStar.com - Tratsche.de - Petteguless.it

  7. #7
    SitePoint Addict dek's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Damir Secki
    @dek:

    it could be the delay.... that onload is executed before the flash is actually loaded, but I don't think so...couse every and each time after refreshing it works great... and if that were the case.. it shouldn't worj in IE too
    ... but it costs nothing to try it

    It was the refreshing thang that suggested to me it might be worthwhile spending the 60 seconds or so to test it out - that and the inconsistency with IE. Oddly enough, the two browsers do have one or two teensy differences here and there (not that you'd normally notice)

    Entirely up to you though
    Only dead fish go with the flow

  8. #8
    SitePoint Enthusiast Damir Secki's Avatar
    Join Date
    Jul 2001
    Location
    Slovenia, Europe
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dek, you know what? It is working! Really, really strange!

    and really thanx alot man!
    Damir Sečki
    PHP (mainly cakePHP)/mySQL/JavaScript (jQuery)/HTML/CSS developer
    BlabberStar.com - Tratsche.de - Petteguless.it

  9. #9
    SitePoint Addict dek's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Damir Secki
    dek, you know what? It is working! Really, really strange!

    and really thanx alot man!
    Now - I'm not the sort of guy who says 'I told you so'...

    But I do so love that that smug feeling

    Glad to have helped.
    Only dead fish go with the flow


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
  •