来源: 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 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 onclick="goTo('http://www.yahoo.com')">
<INPUT TYPE="BUTTON" VALUE=msn onclick="goTo('http://www.msn.com')">
</BODY>
</HTML>