标签:
来源: 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