• 解决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 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>

  • 相关阅读:
    babel的使用以及安装配置
    常见的浏览器兼容性问题与解决方案——CSS篇
    ES6入门——变量的解构赋值
    ES6入门——let和const命令
    第一个移动端项目
    向Github提交更改的代码
    MySQL安装配置
    HTTP 状态消息
    HTMl基础
    Shell 常用的命令
  • 原文地址:https://www.cnblogs.com/huaan011/p/5445986.html
Copyright © 2020-2023  润新知