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 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript working with IE but not with Chrome, help

    Hey Guys!
    I am having a problem with Chrome only (not with IE)...
    I have a swf file loading from html and I am using the following javascript: (old_pedant, from this forum helped me out to write it)

    Code:
    <script type="text/javascript">
    var srch = document.location.search;
    srch = srch.substring(1); // strip off 
    srch = srch.replace(/^\?(actnum|referral)\=[\w]+$/i); // zap all except letters, numbers, underline
        document.write(
       '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
       ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
       ' WIDTH="800" HEIGHT="700" id="MBid">\n'+
       ' <PARAM NAME=movie VALUE="MBid.swf?'+srch+'">\n'+
       ' <PARAM NAME=quality VALUE=high>\n'+
       ' <PARAM NAME=bgcolor VALUE=#333333>\n'+
       ' <PARAM NAME=wmode VALUE=Opaque>\n'+
       ' <EMBED src="MBid.swf'+srch+'"\n'+ 
       '  quality=high bgcolor=#FFFFFF wmode=transparent WIDTH="800" HEIGHT="700" NAME="MBid"\n'+
       '  TYPE="application/x-shockwave-flash"\n'+
       '  PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>\n'+
       '</OBJECT>');
    </script>
    I need to pass from html/java to flash these variables (only sometimes and separated, not at the same time):

    ex: www.mysite.com?actnum=53253838340
    ex: www.mysite.com?referral=user_3

    With IE they are retrieved perfectly, but with Chrome, when entering to the site using one of these links...the site is blank...
    Any ideas where the script might be changed to have the parameter variables working with Chrome too?

    Thanks a lot in advance!!
    Cheers!

  • #2
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyone please?
    Old_Pedant, maybe?

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,658 Times in 4,620 Posts
    Nothing to do with the JavaScript.

    That JS code operates identically on MSIE and Chrome. (Yes, I actually checked.)

    May be an error in what Chrome is expecting for loading up the Flash code.

    Find a working example on Chrome, then let's revisit it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Pedant!
    Thanks a lot for your help!

    I read somewhere else, that it loads different IE from other browsers, here's an example without javascript:

    Code:
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    id="FlashVarsTest" width="100%" height="100%"
    codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
    <param name="movie" value="FlashVarsTest.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <param name="flashVars" value="FlashParameters=Internet Explorer only"/>
    <param name="allowScriptAccess" value="always" />
    <embed src="FlashVarsTest.swf" quality="high" bgcolor="#ffffff"
    width="100%" height="100%" name="FlashVarsTest" align="middle"
    play="true"
    loop="false"
    allowScriptAccess="always"
    type="application/x-shockwave-flash"
    flashVars="FlashParameters=FireFox,Safari,Chrome"
    pluginspage="http://www.adobe.com/go/getflashplayer">
    </embed>
    </object>
    If its the same with Javascript, I don't really know how to implement it, based on this example...but I think that properly formatted to javascript it should work, right?

    Thanks a lot!!!

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,658 Times in 4,620 Posts
    Can you show an actual working example that *does* use parameters?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Pedant!
    I finally found out where the problem is coming from...
    I commented the lines that are giving problems to Chrome (not IE)

    Code:
    <script type="text/javascript">
    var srch = document.location.search;
    //srch = srch.substring(1); // strip off the ... we know rest is valid!
    //srch = srch.replace(/^\?(actnum|referral)\=[\w]+$/i); // zap all except letters, numbers, underline
       document.write(
       '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
       ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
       ' WIDTH="800" HEIGHT="700" id="MBid">\n'+
       //' <PARAM NAME=movie VALUE="MBid.swf?'+srch+'">\n'+
       ' <PARAM NAME=movie VALUE="MBid.swf'+srch+'">\n'+ //new line instead of the above, because of the ?
       ' <PARAM NAME=quality VALUE=high>\n'+
       ' <PARAM NAME=bgcolor VALUE=#333333>\n'+
       ' <PARAM NAME=wmode VALUE=Opaque>\n'+
       ' <EMBED src="MBid.swf'+srch+'"\n'+ 
       '  quality=high bgcolor=#FFFFFF wmode=transparent WIDTH="800" HEIGHT="700" NAME="MBid"\n'+
       '  TYPE="application/x-shockwave-flash"\n'+
       '  PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>\n'+
       '</OBJECT>');
    //}
    </script>
    The problem now is that I have no validation AT ALL...I am back to basics...
    Any ideas how I could implement a new validation without having chrome issues?

    Cheers!!!

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,658 Times in 4,620 Posts
    Sheesh! I am an idiot!

    You can't use replace like that! Where was my head?

    Try this:
    Code:
    <script type="text/javascript">
    var srch = document.location.search;
    srch = srch.substring(1); // strip off 
    var re = /^\?(actnum|referral)\=[\w]+$/i;
    if ( re.test(srch) 
    {
        document.write(
       '[OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
       ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
       ' WIDTH="800" HEIGHT="700" id="MBid">\n'+
       ' [PARAM NAME=movie VALUE="MBid.swf?'+srch+'">\n'+
       ' [PARAM NAME=quality VALUE=high>\n'+
       ' [PARAM NAME=bgcolor VALUE=#333333>\n'+
       ' [PARAM NAME=wmode VALUE=Opaque>\n'+
       ' [EMBED src="MBid.swf'+srch+'"\n'+ 
       '  quality=high bgcolor=#FFFFFF wmode=transparent WIDTH="800" HEIGHT="700" NAME="MBid"\n'+
       '  TYPE="application/x-shockwave-flash"\n'+
       '  PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">[/EMBED>\n'+
       '[/OBJECT>');
    }
    </script>
    (I have [ in there in place of < for testing purposes. Once you see how it works, convert them back to <.)

    Now... This won't even TRY to create the flash if the querystring is wrong.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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