Jump to content

noob question php insert javascript into html body script


millerthegorilla

Recommended Posts

Hi - I am *very* new to php and am trying to insert a line of javascript into script tags in the body of an html page.  Basically, I'm trying to detect the browser type and insert a flash param if the browser is firefox and a different one if not.  Below is my php :

 

function detect_transparent() {

global $ff, $others;

$browser = get_browser();

if($browser->browser == 'Firefox') {

echo($ff);

}

else {

echo($others);

}

 

and here is a section of the script tags in the html :

 

<script>

 

var so = new SWFObject('<?php swfaddress_resource('/website.swf?datasource=datasource.php'); ?>', 'website', '100%', '100%', '9,0,115,0');

<?php detect_transparent(); ?>

so.addParam("allowFullScreen", "true");

...

</script>

 

I know I could use a javascript function to do the same thing but I'd prefer to use php.  The reason I'm doing it is because Firefox freaks out and takes up 99% of the processor when you use flash with wmode = transparent.  The code works fine without the <?php detect_transparent(); ?> function call.  Am I correct in thinking that a php function call like this gets executed server side and then the resulting html page gets passed to the client browser where the client side javascript is called?  If that's right, why does this not work?

 

Thanks in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.