Forum Moderators: open
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
var DivStr,DivID;
var y=300;
var x=300;
var w=110;
function init() {
DivID="Div1";
DivStr="<DIV ID="+ DivID + " style='position:absolute; top:" + y + "; left:" + x + "; width:" + w + "; background-image:url(images/tabs/not_selected.gif);background-repeat: no-repeat;z-index:100;'>"
+"<A HREF='#' target='' onclick='' style='text-decoration: none; color: blue; font-family: arial; font-size:10pt; font-Weight:bold;'>"
+"<p align=center>Above Layer</p>"
+"</a>"
+"</DIV>";
document.write(DivStr);
}
//-->
</SCRIPT>
</HEAD>
<BODY onload=init()>
<table width="700" background="images/styles/blue1x1.gif"><tr><td> </td></tr></table>
</BODY>
</HTML>
Then in the body, take the onLoad event out of the BODY tag and include the document.write line in a script section: document.write(DivStr); //-->
<script type="text/javascript" language="JavaScript">
<!--
</script>
one more question. if DivStr is given a value in a function, just like showed above. it will show "undefined" on the page. do i need some special way to get a variable located in a different script? right now i just comment the function line as follows:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
var DivStr,DivID;
var y=300;
var x=300;
var w=110;
//function init() {
DivID="Div1";
DivStr="<DIV ID="+ DivID + " style='position:absolute; top:" + y + "; left:" + x + "; width:" + w + "; background-image:url(images/tabs/not_selected.gif);background-repeat: no-repeat;z-index:100;'>"
+"<A HREF='#' target='' onclick='' style='text-decoration: none; color: blue; font-family: arial; font-size:10pt; font-Weight:bold;'>"
+"<p align=center>Above Layer</p>"
+"</a>"
+"</DIV>";
//}
//-->
</SCRIPT>
</HEAD>
<BODY >
<script type="text/javascript" language="JavaScript">
<!--
document.write(DivStr);
//-->
</script>
<table width="700" background="images/styles/blue1x1.gif"><tr><td> </td></tr></table>
</BODY>
</HTML>
If that's your situation, you may find help in this thread:
[webmasterworld.com...]