浏览器如果不支持JavaScript,那么就会以页面的内容显示出来。
不过JavaScript有一种标准可以防止这种现象发生,就是利用HTML注释标签去"隐藏" JavaScript的显示。 在脚本代码之前添加
<!-- 结尾处添加
-->就可以了。
<html>
<body>
<script type="text/javascript">
<!--
var r=confirm("Press a button");
if (r==true)
{
document.write("You pressed OK!");
}
else
{
document.write("You pressed Cancel!");
}
//-->
</script>
</body>
</html>
在末尾有两个斜线这是JavaScript注释标记, 防止JavaScript执行
--> 标签。
打开新窗口链接的几种方法:
1.window.open("url");
2.window.location.href="url";
3.自定义函数
<a href="javascript:void(0)" onclick="openWin(1,this)">地球</a>
<script>
function openWin(tag,obj)
{
obj.target="_blank";
obj.href = "Web/test.jsp?no="+tag;
obj.click();
}
</script>
关闭子窗口,并刷新父窗口:
<script> window.opener.location.href=window.opener.location.href;window.close();</script>
window.opener.document.getElementById("TextBox1").value = "想要传回父页面的值";
window.opener.父窗口函数名(要传的值)
继续学习在
http://www.w3schools.com/js/default.asp