码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2016-04-29 14:41:00      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

来源: 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 onclick="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 targetWndName = "MyWindow";
   var wnd = window.open("",targetWndName);
   var link = document.getElementById("link");
   link.target = targetWndName;
   link.href = url;
   link.click();
}
</SCRIPT>
<A ID="link" HREF="javascript:void(0)" style="visibility:hidden;position:absolute;"></A>
<INPUT TYPE="BUTTON" VALUE=yahoo onclick="goTo(‘http://www.yahoo.com‘)">
<INPUT TYPE="BUTTON" VALUE=msn onclick="goTo(‘http://www.msn.com‘)">
</BODY>
</HTML>

  

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

标签:

原文地址:http://www.cnblogs.com/huaan011/p/5445986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!