繁体   English   中英

如何在同一选项卡中同时打开两个链接而不提醒或重定向第一个链接

[英]How to open two link simultaneously in same tab without alerting or redirecting the first one

我必须使用 java 脚本和 HTMl 在同一个选项卡中打开两个链接

<script type="text/javascript">
go(){
windows.open('http://www.yahoo.com');
}
</script>
a href="https://mail.google.com/mail/u/0/?logout&hl=en-GB"onclick = "go();">clickme</a>   

我想要的是; 当有人点击点击我的超链接时,它应该在后台自动运行 Gmail 的注销链接,没有任何警报,并重定向 windows.open('http://yahoo.com') 中的自动链接;

提前致谢

算法将是:

  1. 单击时动态添加 DOM 元素:1x1 像素图像,其源设置为 GMail 注销 URL;
  2. 等待几秒钟(计时器);
  3. 重定向到雅虎。

好的,整个测试页面内容将是:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>test</title>
        <script type="text/javascript">
            function go() {
                var oImg=document.createElement("img");
                oImg.setAttribute('src', 'https://mail.google.com/mail/u/0/?logout');
                oImg.setAttribute('alt', 'na');
                oImg.setAttribute('height', '1px');
                oImg.setAttribute('width', '1px');
                document.body.appendChild(oImg);
                var t=setTimeout("goOn()",1500);
            }
            function goOn() {
                window.location.assign("http://yahoo.com");
            }
        </script>
    </head>
    <body>
    <p><a href="#" onclick="go();return false;">superlink</a></p>
    </body>
</html>

已经在 FFox 中对其进行了测试 - 工作正常:)

最好的方法是创建一个 assincronous 调用以从您想要的任何位置注销

尝试使用 jQuery 获取方法或本教程: http://www.xul.fr/en-xml-ajax.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM