Jump to content

embedding javascript into html


pouncer

Recommended Posts

  <script>
  	if ((screen.width == 1024) && (screen.height == 768)) {
		height1 = '192';
		height2 = '23';
	}
	else if ((screen.width == 1152) && (screen.height == 864)) {
		height1 = '247';
		height2 = '248';
	}
  </script>

 

	<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="247">
          <param name="movie" value="http://ghetto-fusion.com/moschino/flash.swf">
          <param name="quality" value="high">
          <embed src="http://ghetto-fusion.com/moschino/flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="247"></embed>
        </object>

 

where the first width="100%" height="247" .. i need to somehow change it to

 

width="100%" height="height1">

 

and i need to change the second one to

 

width="100%" height="height2">

 

how can i put the javascript vars in the html attributes?

Link to comment
Share on other sites

write the whole thing using JavaScript

<script language="javascript">
var txt = "<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=\""+height1+"\">";
txt += "<param name=\"movie\" value=\"http://ghetto-fusion.com/moschino/flash.swf\">";
txt += "<param name=\"quality\" value=\"high\">";
txt += "<embed src=\"http://ghetto-fusion.com/moschino/flash.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"100%\" height=\""+height2+"\"></embed>";
txt += "</object>";
document.write(txt);
</script>

Link to comment
Share on other sites

First, give two of the element an id for each.

 

... width="100%" height="247" id="object_1">
... width="100%" height="247" id="object_2">

 

Then now implement your js code:

  	if ((screen.width == 1024) && (screen.height == 768)) {
		height1 = '192';
		height2 = '23';
	}
	else if ((screen.width == 1152) && (screen.height == 864)) {
		height1 = '247';
		height2 = '248';
	}
document.getElementById("object_1").height = height1;
document.getElementById("object_2").height = height2;

 

Hope this work, bcoz i never tried out.  :P

 

Hope this help you.

Link to comment
Share on other sites

i even tried this, didn;t work

 

<script>
if ((screen.width == 1024) && (screen.height == 768)) {
	var height = '219';
}
else if ((screen.width == 1152) && (screen.height == 864)) {
	var height = '247';
}

document.write("Your screen res is " + screen.width + "x" + screen.height);
document.write("<br>");
document.write("Your height should be " + height);

document.write('<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=\"'+height+'\">');

document.write('<param name=\"movie\" value=\"http://ghetto-fusion.com/moschino/flash.swf\">');
document.write('<param name=\"quality\" value=\"high\">');
  
document.write('<embed src=\"http://ghetto-fusion.com/moschino/flash.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"100%\" height=\"'+height'\">');

document.write('</object>');
</script>

when i do above code, everything just disappears

Link to comment
Share on other sites

  <script>
  	if ((screen.width == 1024) && (screen.height == 768)) {
		height1 = '192';
		height2 = '23';
	}
	else if ((screen.width == 1152) && (screen.height == 864)) {
		height1 = '247';
		height2 = '248';
	}
	document.getElementById("object_1").height = height1;
	document.getElementById("object_2").height = height2;
  </script>

Is this your code? If it is, so sorry i did't mention you had to put this all under a onload event. Or right before </body>.

 

Let's try this:

  <script>
              window.onload = function(){
  	if ((screen.width == 1024) && (screen.height == 768)) {
		height1 = '192';
		height2 = '23';
	}
	else if ((screen.width == 1152) && (screen.height == 864)) {
		height1 = '247';
		height2 = '248';
	}
	document.getElementById("object_1").height = height1;
	document.getElementById("object_2").height = height2;
              }
  </script>

Link to comment
Share on other sites

huh? what you mean? my code is like this

 

  <script>
  	window.onload = function(){
	if ((screen.width == 1024) && (screen.height == 768)) {
		var height = '219';
	}
	else if ((screen.width == 1152) && (screen.height == 864)) {
		var height = '247';
	}

	document.write("<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='"+height+"'>");

	document.write("<param name='movie' value='http://ghetto-fusion.com/moschino/flash.swf'>");
	document.write("<param name='quality' value='high'>");
	  
	document.write("<embed src='http://ghetto-fusion.com/moschino/flash.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='100%' height='"+height+"'>");

	document.write("</object>");
	}
  </script>

Link to comment
Share on other sites

the exact code works on its own here:

 

http://ghetto-fusion.com/moschino/testt.html

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<table align="center" class="bodyline" width="90%" cellspacing="0" cellpadding="0" border="0"> 

<script>
if ((screen.width == 1024) && (screen.height == 768)) {
	var height = '219';
}
else if ((screen.width == 1152) && (screen.height == 864)) {
	var height = '247';
}

document.write("<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='"+height+"'>");

document.write("<param name='movie' value='http://ghetto-fusion.com/moschino/flash.swf'>");
document.write("<param name='quality' value='high'>");
  
document.write("<embed src='http://ghetto-fusion.com/moschino/flash.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='100%' height='"+height+"'>");

document.write("</object>");
</script>

</table>

<body>
</body>
</html>

 

its just not working in header.html which is like this:

 

<br>

<table align="center" class="bodyline" width="90%" cellspacing="0" cellpadding="0" border="0"> 
<tr> 
	<td align="center" >
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
  
  <script>
  	window.onload = function(){
	if ((screen.width == 1024) && (screen.height == 768)) {
		var height = 219;
	}
	else if ((screen.width == 1152) && (screen.height == 864)) {
		var height = 247;
	}

	document.write("<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='"+height+"'>");

	document.write("<param name='movie' value='http://ghetto-fusion.com/moschino/flash.swf'>");
	document.write("<param name='quality' value='high'>");
	  
	document.write("<embed src='http://ghetto-fusion.com/moschino/flash.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='100%' height='"+height+"'>");

	document.write("</object>");
	}
  </script>


	<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="247">
          <param name="movie" value="http://ghetto-fusion.com/moschino/flash.swf">
          <param name="quality" value="high">
	  
          <embed src="http://ghetto-fusion.com/moschino/flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="247">
	  </embed>
        </object>




	<br/>
	<br/>
  </tr>
</table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="100%" height="20" border="0" cellpadding="4" cellspacing="0" background="themes/fisubice/images/cellpic_nav.gif">
            <tr>
              <td width="165" nowrap><font class="content">$theuser</font></td>
              <td nowrap><div align="center"><font class="content"> &#8226; <a href="index.php">Home</a> &#8226; <a href="modules.php?name=Downloads">Downloads</a> &#8226; <a href="modules.php?name=Your_Account">Your Account</a> &#8226; <a href="modules.php?name=Forums">Forums</a> &#8226; </font></div></td>
              <td width="165" nowrap><div align="center"><font class="content">
$datetime
                  </font></div></td>
            </tr>
          </table></td>
      </tr>
    </table>
    <table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
      <tr valign="top">
        <td><center>$public_msg</center></td>
</tr></table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr valign="top">
  <td valign="top" width="1" background="themes/fisubice/images/7px.gif">

 

header.html is part of php nuke software, its the header fr my theme

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.