简体   繁体   English

如何在不丢失引荐来源的情况下打开新标签页?

[英]How to open new tab without losing referer?

My purpose is open new tab without losing referer. 我的目的是在不丢失引荐来源的情况下打开新标签页。 So, I have this code: 所以,我有这段代码:

$(document).click(function() {
    window.open('http://www.google.com', '_blank');
});

It worked like a charm but it doesn't keep referer when I use IE browser. 它的工作原理很吸引人,但是当我使用IE浏览器时却无法保留引用。 I search and see below code but I don't how to apply to my problem. 我搜索并看到下面的代码,但是我没有如何解决我的问题。

<form action="http://google.com" method="get" name="redirect"></form>
<script> document.forms['redirect'].submit() </script>

So, there is any way which work for all browser ? 那么,有什么方法可以适用于所有浏览器吗?

<input type="text" name="q" onkeypress="doit(event,this.value)"/>

<script type="text/javascript">
function doit(e,value){
if (e.which == 13){//or e.keyCode
     window.open('http://www.google.com/?#q='+value, '_blank');
  }
}
</script>

edit: you don't need form just use input and javascript function to check if user hits enter then open the new page with value which user types. 编辑:您不需要表格,只需使用输入和javascript函数来检查用户是否按回车键,然后使用用户输入的值打开新页面。

When linking from one document to another in Internet Explorer 4.0 and later, the Referer header will not be sent when the link is from an HTTPS page to a non-HTTPS page. 在Internet Explorer 4.0和更高版本中从一个文档链接到另一个文档时,当链接是从HTTPS页面到非HTTPS页面时,将不会发送Referer标头。 The Referer header also will not be sent when the link is from a non-HTTP(S) protocol, such as file://, to another page. 当链接从非HTTP(S)协议(例如file://)到另一个页面时,Referer标头也不会发送。 for more info go to this link 有关更多信息,请转到此链接

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

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