js windows.open弹出页被阻止

js中用windows.open弹出一页面,但是在浏览器中弹出窗体被阻止请问怎么样能被解决呢~~~... js中 用windows.open弹出一页面,但是在浏览器中 弹出窗体被阻止 请问怎么样能被解决呢~~~ 展开
 我来答
橘子情报局
2010-02-24 · TA获得超过6031个赞
知道大有可为答主
回答量:4113
采纳率:50%
帮助的人:2689万
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Example</title>
<script type="text/JavaScript">
window.onload = function() {
if (!document.getElementsByTagName) return false;
var lnks = document.getElementsByTagName("a");
for (var i=0; i<lnks.length; i++) {
if (lnks[i].getAttribute("class") == "popup") {
lnks[i].onclick = function() {
popUp(this.getAttribute("href"));
return false;
}
}
}
}

function popUp(winURL) {
window.open(winURL,"popup","width=320,height=480");
}

</script>
</head>
<body>
<a href="http://www.example.com/" class="popup">Example</a>
</body>
</html>
余刚素安寒
2019-01-16 · TA获得超过3735个赞
知道大有可为答主
回答量:3107
采纳率:26%
帮助的人:175万
展开全部
<!DOCTYPE
html
PUBLIC
"-//W3C//DTD
XHTML
1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en">
<head>
<meta
http-equiv="content-type"
content="text/html;
charset=utf-8"
/>
<title>Example</title>
<script
type="text/JavaScript">
window.onload
=
function()
{
if
(!document.getElementsByTagName)
return
false;
var
lnks
=
document.getElementsByTagName("a");
for
(var
i=0;
i<lnks.length;
i++)
{
if
(lnks[i].getAttribute("class")
==
"popup")
{
lnks[i].onclick
=
function()
{
popUp(this.getAttribute("href"));
return
false;
}
}
}
}
function
popUp(winURL)
{
window.open(winURL,"popup","width=320,height=480");
}
</script>
</head>
<body>
<a
href="http://www.example.com/"
class="popup">Example</a>
</body>
</html>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式