Location. href has many usage methods in js mainly to control page navigation or jump to the upper-level framework page. Below I have sorted out the location for you. the href address jump parameter introduction is helpful to you.
Location. href in javascript has many usage methods, mainly as follows.
Top. location. href = "url" opens the url on the top-level page (jump out of the Framework)
Self. location. href = "url" only opens the url address on this page
Parent. location. href = "url" opens the Url address in the parent window.
This. location. href = "url" is used in the same way as self.
Location. href = "/url" the current page opens the URL page
Windows. location. href = "/url": the current page opens the URL page. The previous three operations are the same.
If the frame is customized on the page, you can replace parent self top with the name of the custom frame to open the url address in the frame window.
In addition, window. location. href = window. location. href; and window. location. Reload () both refresh the current page. The difference is whether data is submitted. When data is submitted, window. location. Reload () will prompt whether to submit. window. location. href = window. location. href; then the data is submitted to the specified url.
The location page jumps to js as follows:
The Code is as follows: |
Copy code |
// Simple jump Function gotoPage (url) { // Eg. var url = "newsview.html? Catalogid = "+ catalogID +" & pageid = "+ pageid; Window. location = url; } // Upgrade the location usage to pass parameters for a single page Function goto_catalog (iCat) { If (iCat <= 0) { Top. location = "../index. aspx"; // top } Else { Window. location = ".../newsCat. aspx? Catid = "+ iCat; } } // Jump to the page of the specified framework. Both methods are available. Function goto_iframe (url) { Parent. mainFrame. location = ".../index. aspx ";// // Parent.doc ument. getElementById ("mainFrame"). src = ".../index. aspx"; // use dom to change page // At the same time, I added dom writing. } // Jump to the page for the specified framework, because parent. iframename. location = ".. /index. aspx "; the method cannot be implemented, mainly" parent. iframename in iframename is set as a node by default in js, but the passed parameters cannot be converted. Therefore, dom is used to implement the frame jump page for passing two parameters, I hope that this old man will be enlightened! Function goto_iframe (iframename, url) { Parent.doc ument. getElementById (iframename). src = ".../index. aspx"; // use dom to change page by iframeName //} // Return to the home page Function gohome () { Top. location = "/index. aspx "; } </Script> |