Not signed in (Sign In)

Vanilla 1.0.3 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorlouiswalch
    • CommentTimeAug 16th 2007
     
    Having an issue with IE6 reporting js errors on pages containing more then one swfobject call. See this page:

    http://dev.sundancechannel.com/ie6js.php

    If i comment out so.write("flash-header");, it will work. But there are still more then one swfobject call on that page. It's something to do with the header.

    Can you tell what the problem is? Please help, driving me nuts.

    Thank you.
    • CommentAuthorphilip
    • CommentTimeAug 16th 2007
     
    it's because you're using the same variable name for each SWFObject instance. you need to use unique names. you also gave two SWFs the same ID. they need unique IDs.

    this:

    <div id="flash-header"></div>
    <script type="text/javascript">
    var so = new SWFObject("/common/swf/header.swf",
    "header", "967", "110", "8", "#333333");
    so.setAttribute('redirectUrl', '/noflash');
    so.addVariable("conf_uri", "/common/swf/config_header.xml");
    so.addVariable("item", "SELECTS");
    so.write("flash-header");
    </script>

    <div id="sideBox_connectionEngine"></div>
    <script type="text/javascript">
    var so = new SWFObject("/common/swf/connection_engine.swf",
    "connectionEngine", "235", "382", "8", "#333333");
    so.addVariable("conf_uri", "/common/swf/config_connection_engine.xml");
    so.write("sideBox_connectionEngine");
    </script>

    <div id="flash-minischedule"></div>
    <script type="text/javascript">
    var so = new SWFObject("/common/swf/minischedule.swf",
    "header", "967", "35", "8", "#333333");
    so.addVariable("conf_uri", "/common/swf/config_minischedule.xml");
    so.write("flash-minischedule");
    </script>


    should be this (or similar):

    <div id="flash-header"></div>
    <script type="text/javascript">
    var soHeader = new SWFObject("/common/swf/header.swf",
    "header", "967", "110", "8", "#333333");
    soHeader.setAttribute('redirectUrl', '/noflash');
    soHeader.addVariable("conf_uri", "/common/swf/config_header.xml");
    soHeader.addVariable("item", "SELECTS");
    soHeader.write("flash-header");
    </script>

    <div id="sideBox_connectionEngine"></div>
    <script type="text/javascript">
    var soConEngine = new SWFObject("/common/swf/connection_engine.swf",
    "connectionEngine", "235", "382", "8", "#333333");
    soConEngine.addVariable("conf_uri", "/common/swf/config_connection_engine.xml");
    soConEngine.write("sideBox_connectionEngine");
    </script>

    <div id="flash-minischedule"></div>
    <script type="text/javascript">
    var soMiniSched = new SWFObject("/common/swf/minischedule.swf",
    "minischedule", "967", "35", "8", "#333333");
    soMiniSched.addVariable("conf_uri", "/common/swf/config_minischedule.xml");
    soMiniSched.write("flash-minischedule");
    </script>


    hyphens in IDs sometimes cause issues with Flash, too... i'd avoid them if possible. stick to underscore or camelCase. :)

    - philip
    • CommentAuthorphilip
    • CommentTimeAug 16th 2007
     
    • CommentAuthorlouiswalch
    • CommentTimeAug 16th 2007
     
    Ahhh... thank you Phillip.

    Can I ask, why each SWFObject instance needs a unique id? With the var before the declaration, isn't it just writing over the previous so variable?
    • CommentAuthorphilip
    • CommentTimeAug 16th 2007
     
    while that will work in most browsers (redeclaring variables is 'legal' in JavaScript), i don't think it's a good practice. in some cases, it can mess up references to the var -- am i referencing the first one, the most recent one, or something in between? it also makes it harder for others to read your code, in case a coworker or someone like me is trying to help.

    using unique identifiers is so easy, and greatly reduces chances of errors... why take any chances? :)

    - philip
    • CommentAuthorlouiswalch
    • CommentTimeAug 16th 2007
     
    Thanks for the input. I took your suggestions, and gave all js vars unique names, as well as all flash names.

    Here is a page which I just cut out all the swf objects from our film overview page, you can see there is a lot. They all have unique names, and still getting errors in IE. Any idea

    http://dev.sundancechannel.com/swfobject_tests/films.php
    • CommentAuthorGeoff
    • CommentTimeAug 16th 2007
     
    you should be able to re-use the 'so' var if you want - just that as phillip said, re-declaring vars is usually discouraged in the js world.

    my guess is you are having issues because of the hyphens in the div ids - try taking those out and see what happens.

    I noticed I get exactly two js errors, and only two of the swf divs have hyphens in them.
    • CommentAuthorphilip
    • CommentTimeAug 16th 2007
     
    it hangs in Firefox, too. i'm not sure what to tell you... most of the SWFs load ok, and at some point the page stops loading.

    for one thing, i've never seen so many SWFs loaded onto one page. maybe the browser/plugin can't handle so many at once? i'm not sure if anyone ever tested that... sounds like i'm headed over to google as soon as i finish writing this! :)

    the first thing i'd do is change any IDs (including DIV ids) containing hyphens to camelCase. as i mentioned before, this sometimes chokes Flash Player.

    secondly, i'd simplify the page for troubleshooting purposes: disable any non-SWFObject JavaScript you have on your page, such as SIFR. if the page loads without errors, you'll know it isn't the SWFObject code.

    or vice versa: remove the SWFObject code and use the traditional object/embed method for testing purposes. if the page loads fine, maybe something conflicts with SWFObject.

    - philip
    • CommentAuthorlouiswalch
    • CommentTimeAug 16th 2007
     
    Oi, changing all the div ids... ok.
    I will have to look at this next week.

    Yea i know, talk about alot of swf calls, we have pages with atleast double this too :)

    Thanks for the advice.
    • CommentAuthorzhangsisi
    • CommentTimeOct 1st 2007
     
    find love www.ConnectAsia.info/en/lang104082about_sisi11 welcome you