javascript 小技巧(自己总结)

来源:互联网 发布:随机时间序列预测算法 编辑:程序博客网 时间:2024/05/17 18:25

1、 弹出窗口关闭时给出提示信息(在弹出的页面加上以下代码):

<script>
function IsSureClose()
{
    
return event.returnValue='asdfasf';
}

</script>
<body onbeforeunload="IsSureClose()">
</body>

2、JavaScript中window和document的区别:
   documentwindow的一个子对象。window.document,因为window可以省略,所以一般只写document。似的还有window.historywindow指窗体,document指页面。documentwindow的一个子对象。
    window.open()
document.open()是完全不同的
    window.open()
是打开一个窗口,返回这个窗口的名称
   而document.open()是用来打开输出流的,相对应的有document.close()来关闭输出流之间用document.write()来输出文本只是document.write()本来就可以打开输出流,所以document.open()其实可以不写的。