怎样在html中调用javascript中的数据,该如何解决
怎样在html中调用javascript中的数据
如上代码 我想在*******行中调用script中的w变量,可是在浏览器上调试时发现不对,那么应该怎样改呢??先谢谢各位了
------解决方案--------------------
不是这样子的,应该在javascript函数中把w,h计算后改变div的width和heigh
------解决方案--------------------
- HTML code
<html> <head> <title> 左右 </title> </head> <body> <div style="position:absolute;top:0;left:0;width:w;height:100;background-color:blue"> ********* <marquee> <img src="tx.jpg"> </marquee> </div> <div style="position:absolute;top:0;left:w;width:w;height:100;background-color:yellow"> ******* <marquee direction=right> <img src="tx2.jpg"> </marquee> </div> <script> var w=screen.availWidth; w=w/2; var h=screen.availHeight; h=h/2; </script> </body> </html>
如上代码 我想在*******行中调用script中的w变量,可是在浏览器上调试时发现不对,那么应该怎样改呢??先谢谢各位了
------解决方案--------------------
不是这样子的,应该在javascript函数中把w,h计算后改变div的width和heigh
------解决方案--------------------
- HTML code
<html> <head> <title> 左右 </title> </head> <body> <div id="div1" style="position:absolute;top:0;left:0;width:w;height:100;background-color:blue"> ********* <marquee> <img src="tx.jpg"> </marquee> </div> <div id="div2" style="position:absolute;top:0;background-color:yellow"> ******* <marquee direction=right> <img src="tx2.jpg"> </marquee> </div> <script> var w=screen.availWidth; w=w/2; var h=screen.availHeight; h=h/2; var ddd= document.getElementById("div2"); ddd.style.width=w; ddd.style.height=h; </script> </body> </html>