搜索
写经验 领红包
 > 电器

html中弹窗(html弹窗代码大全)

导语:07,html弹窗,及窗口间通信和location

html中弹窗(html弹窗代码大全)

(1),弹窗及参数说明

<!DOCTYPE html><head><meta charset=&34;>    <style type=&34;></style><link rel=&34; type=&34; href=&&34;button&34;打开新窗口&34;openNewWin()&34;text/javascript&34;newTest.html&34;弹到新窗口&34;height=500, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no&39;&34;utf-8&34;text/css&34;stylesheet&34;text/css&34;34;></head><input type=&34; value=&34; onclick=&34; /><script type=&34;>function testOpenCenterWindow() {// 窗口垂直位置水平位置var iTop = (window.screen.availHeight - 30 - 500) / 2;var iLeft = (window.screen.availWidth - 10 - 800) / 2; //减widthvar openWindow = window.open(&34;,&34;,&34;+ iTop+&34;+ iLeft+&34;);}</script>

(3),窗口 location属性

window对象location属性是引用Location对象,它表示该窗口显示文档的URLwindow.location.href=&34;;  //当前窗口显示指定页面window.close();                                 //关闭本页面

(4),窗口与父窗口通信

(1) 使用window.open()创建的窗口与父窗口通信  可以在子窗口页面中通过window.opener来获取父窗口对象,获取之后子窗口便可以对父窗口执行刷新,传值等操作。window.opener.location.reload();     //子窗口刷新父窗口window.opener.location.href            //获取父窗口href//设置父窗口元素值window.opener.document.getElementById(&34;).value=&34; ;

本文内容由小心整理编辑!