JavaScript Location.href Address Jump detailed

Source: Internet
Author: User

There are many uses of location.href in JavaScript, mainly as follows.
 
top.location.href= "url" opens the URL on the top-level page (out of the frame)

self.location.href= "url" opens URL address only on this page

parent.location.href= "url" opens the URL address in the parent window

this.location.href= the "url" usage is consistent with the use of self

location.href= "/url" Current page Open URL page

windows.location.href= the current page of "/url" opens the URL page, the previous three usages are the same.


If the page has a custom frame, you can change parent self top to the name of the custom frame, which opens the URL address in the frame window

In addition, Window.location.href=window.location.href and Window.location.Reload () and both are refreshing the current page. The difference is whether the data is submitted. When there is a submission, window.location.Reload () prompts for the submission, Window.location.href=window.location.href, and submits the data to the specified URL

Location page Jump JS as follows:

  code is as follows copy code

//Simple jump
function gotoPage (URL)
{
//eg. var url = "newsview.html?catalogid=" +catalogid+ "&pageid=" +pag Eid
window.location = URL;
}
//Upgrade to location usage, pass parameters for individual pages
function Goto_catalog (icat)
{
if (icat<=0)
{
Top.locati On = ". /index.aspx "; Top out
}
Else
{
Window.location = "... /newscat.aspx?catid= "+ICAT;
}

//jump page for specified frame, two methods are available
function goto_iframe (URL)
{
Parent.mainFrame.location = "... /index.aspx ";
//Parent.document.getElementById ("MainFrame"). src = ". /index.aspx ";/use DOM to change page//At the same time I added the DOM to the
}
//Jump page for the specified frame because parent.iframename.location=" ... /index.aspx "; Methods can not be implemented, mainly "Parent.iframename" in the Iframename in JS is the default node, and can not transfer the parameters passed over, so with the DOM to achieve the pass two parameters of the frame jump page, I hope that the man is not hesitate to enlighten!
Function Goto_iframe (iframename,url)  
{
Parent.document.getElementById (iframename). src = ". /index.aspx;/Use DOM to change page by Iframename

//}
//Back to Home
function GoHome ()
{
Top.location = "/index.aspx";
}
</script>

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.