网站首页 > 教程文章 正文
(1),弹窗及参数说明
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css"></style>
<link rel="stylesheet" type="text/css" href="#">
</head>
<body>
<input type="button" value="打开新窗口" onclick="openNewWin()" />
</body>
<script type="text/javascript">
function openNewWin() {
var openWindow = window.open("newTest.html",
"弹到新窗口",
"height=500, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
}
/***
(00) window.open 弹出新窗口的命令
(01) newTest.html 弹出窗口的文件名,或请求地址
(02) 弹出窗口的名字(不是文件名),非必须,可用空''代替
(03) height=100 窗口高度
(04) width=400 窗口宽度
(05) top=0 窗口距离屏幕上方的像素值
(06) left=0 窗口距离屏幕左侧的像素值
(07) toolbar=no 是否显示工具栏,yes为显示
(08) menubar 表示菜单栏
(09) scrollbars 表示滚动栏
(10) resizable=no 是否允许改变窗口大小,yes为允许
(11) location=no 是否显示地址栏,yes为允许
(12) status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许
***/
</script>
</html>
(2),弹窗并居中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css"></style>
<link rel="stylesheet" type="text/css" href="#">
</head>
<body>
<input type="button" value="弹出的窗口居中" onclick="testOpenCenterWindow()" />
</body>
<script type="text/javascript">
function testOpenCenterWindow() {
// 窗口垂直位置水平位置
var iTop = (window.screen.availHeight - 30 - 500) / 2;
var iLeft = (window.screen.availWidth - 10 - 800) / 2; //减width
var openWindow = window.open("newTest.html"
,"测试弹窗口并居中"
,"height=500, width=800, top="+ iTop
+", left="+ iLeft
+", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no"
);
}
</script>
</html>
(3),窗口 location属性
window对象location属性是引用Location对象,它表示该窗口显示文档的URL
window.location.href="page1.jsp"; //当前窗口显示指定页面
window.close(); //关闭本页面
(4),窗口与父窗口通信
(1) 使用window.open()创建的窗口与父窗口通信
可以在子窗口页面中通过window.opener来获取父窗口对象,获取之后子窗口便可以对父窗口执行刷新,传值等操作。
window.opener.location.reload(); //子窗口刷新父窗口
window.opener.location.href //获取父窗口href
//设置父窗口元素值
window.opener.document.getElementById("loginname").value="return1" ;
猜你喜欢
- 2024-12-01 Shopify模版编辑器问题排查及解决办法汇总
- 2024-12-01 JS实现防止别人通过控制台调试网站
- 2024-12-01 Web安全防范知识基础讲解
- 2024-12-01 「Shopify」屏蔽国内同行卖家访问网站
- 2024-12-01 避免网站中出现 index.html
- 2024-12-01 实现网页跳转的方法
- 2024-12-01 将 Safari 打造成 iOS 里的快速启动中心:Bookmarklet
- 2024-12-01 JMeter主要组件介绍(一)
- 2024-12-01 H5浏览器直接调起微信(url协议 weixin:// )判断是否安装微信
- 2024-12-01 HTTP GET如何在分页查询时传递中文参数值
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- md5 sha1 (32)
- mybatis plus page (35)
- semaphore 使用详解 (32)
- update from 语句 (32)
- vue @scroll (38)
- 堆栈区别 (33)
- 在线子域名爆破 (32)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)