...

View Full Version : javascript working with IE but not with Chrome, help



nightkarnation
07-18-2012, 06:11 AM
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)



<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!

nightkarnation
07-18-2012, 08:05 PM
Anyone please?
Old_Pedant, maybe?

Old Pedant
07-18-2012, 10:09 PM
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.

nightkarnation
07-19-2012, 03:00 AM
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:



<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!!!

Old Pedant
07-19-2012, 03:28 AM
Can you show an actual working example that *does* use parameters?

nightkarnation
07-19-2012, 04:34 AM
Pedant!
I finally found out where the problem is coming from...
I commented the lines that are giving problems to Chrome (not IE)



<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!!!

Old Pedant
07-19-2012, 09:59 PM
Sheesh! I am an idiot!

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

Try this:


<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum