Log in

View Full Version : How should I write this javascript in php



Dennis_Gull
04-10-2007, 03:01 AM
Hello, I got some problems with my php code, im trying to use a javascript to remove the "click here to activate" but I got some problems, take a look at this code, at AC_FL_RunContent( 'codebase' all the text become "bugged" because I already used one ' before. Anyways here it is:


<?php
$link = '<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="Scripts/AC_ActiveX.js" type="text/javascript"></script>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','100','height','100','src','click_test','quality','high','FlashVars','file=<?php echo $numb; ?>','wmode','opaque','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','click_test' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="100">
<param name="movie" value="click_test.swf" />
<param name="quality" value="high" />
<param name="FlashVars" value="file=<?php echo $numb; ?>" />
<param name="wmode" value="opaque" />
<embed src="click_test.swf" quality="high" FlashVars="<?php echo $numb; ?>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="100" height="100"></embed>
</object></noscript>';
?>

At first I was just going to end the tag ?> and then place the javascript and then open the php tag again with <?php

But the $link = file doesnt work then... im not sure what to do now, should I try to use " or ´?

thetestingsite
04-10-2007, 03:05 AM
You will need to escape the quotes like so:



<?php
$link = '<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="Scripts/AC_ActiveX.js" type="text/javascript"></script>
<script type="text/javascript">
AC_FL_RunContent( \'codebase\',\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\',\'width\',\'100\',\'height\',\'100\',\'src\',\'click_test\',\'quality\',\'high\',\'FlashVars\',\'file='.$numb.'\',\'wmode\',\'opa que\',\'pluginspage\',\'http://www.macromedia.com/go/getflashplayer\',\'movie\',\'click_test\' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="100">
<param name="movie" value="click_test.swf" />
<param name="quality" value="high" />
<param name="FlashVars" value="file='.$numb.'" />
<param name="wmode" value="opaque" />
<embed src="click_test.swf" quality="high" FlashVars="'.$numb.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="100" height="100"></embed>
</object></noscript>';
?>


Also, while you are still within the php tags, you do not need to call variables like so: <?php echo $numb;?>, but instead call them directly (as I fixed in the code above).
Hope this helps.

djr33
04-10-2007, 03:26 AM
This is a way to avoid such situations, when there's a long string of text:
<?php
$var = <<<OUT
anything you want here... whatever
line breaks, etc.
just fine.
OUT;
?>

Just be sure to start and end just like that, with the same 'word' (or whatever), and the <<</; setup.
It works great.

Or, you can just end the PHP, like this--
if (1==1) { ?> hello <?php }

That would only write that html if the IF evaluates to true.

Dennis_Gull
04-10-2007, 05:02 AM
Thanks the code worked great however the script didnt :(

I get this wmode bugg in mozilla, when you use the scroll the object get inactive.

djr33
04-10-2007, 05:10 AM
It's a bit vague at this point, not being able to see the page.
Since PHP code needs to first be parsed, it'll be easier to work with the output html.
A link to your page would be very helpful.

Dennis_Gull
04-10-2007, 05:57 AM
The code worked, all the data was correct but the thing is wmode will make the flash inactive when using the scroller if your browsing with mozilla. Even adobes own homepage example of wmode is bugged which is quite ironic :D
I thought there was a workaround but guess theres not I think I will go with the swfobject.js method now as its less code.