日期:2014-05-16 浏览次数:20390 次
<script language="javascript"> var g = "I'm here"; </script> <script tpye="text/javascript" src="test.js"></script>
alert(g);
<script tpye="text/javascript" src="test.js?a=1&b=2" id="testjs"></script>
var test = document.getElementById("testjs"); var src = test.getAttribute("src"); alert(src.substring(src.indexOf('?')+1));
<script tpye="text/javascript" src="test.js" data="a=1&b=2" id="testjs"></script>
var test = document.getElementById("testjs"); alert(test.getAttribute("data"));
<script tpye="text/javascript" src="test.js"> var temp = "just test"; </script>
var script = document.getElementsByTagName("script"); eval(script[script.length-1].innerHTML); alert(temp);
<script> document.cookie = "g=I'm here"; </script> <script tpye="text/javascript" src="test1.js"></script>
------解决方案--------------------
--test2.html--
<script> location.hash = "g=I'm here"; </script> <script tpye="text/javascript" src="test2.js"></script>
------解决方案--------------------
--test3.html--
<script> window.name = "g=I'm here"; </script> <script tpye="text/javascript" src="test3.js"></script>
------解决方案--------------------
大叔那也算啊?
那下面的岂不是也算?
<script> var s = 1; </script> <script language="javascript" src="xx.txt"></script>
------解决方案--------------------
一般不赞成在外部js中直接调用或执行函数
一般全局变量可以任何地方调用。
如果实在要用,可以试试下这种方法。
<script tpye="text/javascript" src="test.php?a=1&b=2"></scr