解决IE中window.open打开链接refer丢失的问题

来源: http://www.coderanch.com/t/114767/HTML-CSS-JavaScript/nClick-window-open-loses-referrer
Hello,I have a table with cells, and the complete area of each cell should be a clickable link (not only the text in it). Therefore I couldn't use normal hyperlinks, and instead did this as follows, in javascript, for each cell:
<p><input οnclick="window.open('http://www.somesite.com')" type="button" value="按钮" /></p>
After a while I noticed that the newly opened windows don't have any referrer info. I guess that's because of the "window.open" method.
answer:
<HTML>
<BODY >
<SCRIPT LANGUAGE="JavaScript">
function goTo(url){
var link = document.getElementById("link");
if (!link) { link = document.createElement("a"); }
link.style.display = "none";
document.body.appendChild(link);
link.target = "_blank";
link.href = url;
link.click();
}
</SCRIPT>
<A ID="link" HREF="javascript:void(0)" style="visibility:hidden;position:absolute;"></A>
<INPUT TYPE="BUTTON" VALUE=yahoo οnclick="goTo('http://www.yahoo.com')">
<INPUT TYPE="BUTTON" VALUE=msn οnclick="goTo('http://www.msn.com')">
</BODY>
</HTML>

转载于:https://www.cnblogs.com/huaan011/p/5445986.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值