javascript 小技巧(自己总结)

    技术2022-05-11  81

    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()其实可以不写的。


    最新回复(0)