Open a new window and keep the page referrer

Source: Internet
Author: User
Tags window
Page

When we usually need to open a new window, we take one of the following three: (I don't know if there are any other ways)

1. Open a new page through a link
<a href= "http://www.simplelife.cn" target= "_blank" >open a new window</a>

2. Open a new window through the window.open () function of JavaScript
<script>
window.open ("http://www.simplelife.cn");
</script>

3. Submit to a new page through form forms
<form action= "http://www.simplelife.cn" target= "_blank" >
Open a new window
</form>

Sometimes, we not only want to open a new window, but also want to open the new window has referrer information, so that statistical antecedents.

Through the experiment found: in the Firefox browser, the above three ways in the new window can be successfully retained referrer, and in IE browser, the second way can not retain referrer.

In some applications, such as the need to do some data validation before opening the window and so on, do not allow us to use the link to open a new window, but must use JavaScript to open a new window, this time if you need to retain referrer, the experiment can only use the following way:

<font >Go</font>
<form name=jumpform id=jumpform action= "target=" _blank "method=post>"
</form>
<script>
function Go (URL) {
var form = document.getElementById ("Jumpform");
Form.action=url;
Form.submit ();
}
</script>

Sometimes, you need to jump to the URL is required parameters, such as:
Http://www.simplelife.cn/blog/index.php?op=ViewArticle&articleId=193&blogId=1

In this case, if you use the form form's Get method submission, you will cause the URL to carry the parameters can not transfer past, can only be submitted using post, so the above program uses post to submit the form.

This way: You can open a new window, and you can keep the referrer complete solution.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.