请教网页弹出窗口的问题?

bluewg2009 2009-09-20 11:52:17
要求:
假如:在www.a.com网页中点击一个链接打开www.b.com网站的一个网页
b网页打开后又弹出一个网页覆盖a网页。


目的:就是在打开我的网页后,再弹出一个网页覆盖来源网页。
...全文
71 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluewg2009 2009-09-20
  • 打赏
  • 举报
回复
是不是判断来源网页域名时有问题?
bluewg2009 2009-09-20
  • 打赏
  • 举报
回复
<script language="javascript" type="text/javascript">
var ref = '';
if (document.referrer.length > 0 && document.referrer.indexOf("www.a.com")!=-1) {
ref = document.referrer;
parent.window.location.href='http://www.xxx.com'; }
try {
if (ref.length == 0 && opener.location.href.length > 0 && && document.referrer.indexOf("www.a.com")!=-1)) {
ref = opener.location.href;
parent.window.location.href='http://www.xxx.com'; }
} catch (e) {}
</script>
====
代码试了一下,怎么没有弹出网页哦?
bluewg2009 2009-09-20
  • 打赏
  • 举报
回复
in0512, 好像你的代码不行,没有弹出网页。提示第七行代码错误。
in0512 2009-09-20
  • 打赏
  • 举报
回复
<script language="javascript" type="text/javascript">
var ref = '';
if (document.referrer.length > 0 && document.referrer.indexOf("www.a.com")!=-1) {
ref = document.referrer;
parent.window.location.href='http://www.xxx.com'; }
try {
if (ref.length == 0 && opener.location.href.length > 0 && && document.referrer.indexOf("www.a.com")!=-1)) {
ref = opener.location.href;
parent.window.location.href='http://www.xxx.com'; }
} catch (e) {}
</script>
bluewg2009 2009-09-20
  • 打赏
  • 举报
回复
谢谢楼上回复。

但是又有一个问题:
<script>parent.window.location.href='http://www.xxx.com'; </script>
这个代码导致如果是直接输入网址时,把来源页定为了自己,直接覆盖了自己的网页

怎样做到弹出页面只覆盖指定域名的来源页面?
比如,弹出网页只覆盖来源来 www.a.com域名的来源网站,而其它域名的来源网页则不弹出网页.
in0512 2009-09-20
  • 打赏
  • 举报
回复
写错了,应该是
window.opener.location.href
in0512 2009-09-20
  • 打赏
  • 举报
回复
b
<script>parent.window.location.href='http://www.xxx.com';</script>
bluewg2009 2009-09-20
  • 打赏
  • 举报
回复
代码应该怎样写? 谢谢赐教
in0512 2009-09-20
  • 打赏
  • 举报
回复
第7行多了&&这个

parent.window.location.href一般是指父窗口的跳转,一般用于iframe

window.opener.location.href应该使用这个,弹出窗口后的父窗口

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧