如何防止使用JavaScript弹出窗口?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何防止使用JavaScript弹出窗口?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1882字,纯文字阅读大概需要3分钟。
内容图文
![如何防止使用JavaScript弹出窗口?](/upload/InfoBanner/zyjiaocheng/653/7be2554083314a589d8f1bfb8a4fa5b4.jpg)
无论如何,我可以使用JavaScript阻止来自其他网站(iframe)的弹出窗口吗?
示例:我有一个网站,该网站可链接到其他几个网站.其中之一具有这样的弹出脚本:
<script type="text/javascript">
var popunder=new Array()
popunder[0]="http://www.target.com"
//Specify the width and height of new popunder window (in pixels).
var width = '700';
var height = '450';
//these are obvious variables. set "yes" or "no".
var p = 'scrollbars=yes, resizable=yes, toolbar=yes,' + 'menubar=yes, status=yes, location=yes, left=85, top=20, height=' + height + ',width=' + width;
// Load new PopUnder only once per browser session? (0=no, 1=yes)
// Putting 0 will cause the Popunder to load every time page is loaded
// Specifying 1 will cause it to load only once per session
var one_time=0
// That's it! Don't edit the code below unless you're really good. :-P //
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
//set the index of beginning value
end = document.cookie.indexOf(";", offset);
if (end == -1) // set the index of the end of cookie value
end = document.cookie.length;
returnvalue = unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadornot(){
if (get_cookie('popunder')==''){
load_pop_power()
document.cookie="popunder=yes"
}
}
function load_pop_power(){
win2 = window.open(popunder[Math.floor(Math.random()*(popunder.length))], "bw", p)
win2.blur()
window.focus()
}
if (one_time==0)
load_pop_power()
else
loadornot()
</script>
如果不能阻止此弹出窗口,并且用户在firefox或IE上的安全性设置较低.
我有事.网站上的iframe:(iframe.php)
<iframe src="http://friend.com/pop.php"></iframe>
我应该在iframe.php页面上做什么以防止弹出窗口?
解决方法:
这是不可能的. wdm是正确的.但此处提供了更详细的答案.
How to block pop-up coming from iframe?
内容总结
以上是互联网集市为您收集整理的如何防止使用JavaScript弹出窗口?全部内容,希望文章能够帮你解决如何防止使用JavaScript弹出窗口?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。