Javascript cross-origin refresh implementation code

Source: Internet
Author: User

The three pages are separated into main.htm, left.htm, and right.htm in the same window.
Main.htm Copy codeThe Code is as follows: <Head>
<Title> implementation across </title>
</Head>
<Body>
<Div> Main Window </div>
<Iframe id = "left" name = "left" width = "500px" height = "300px;" src = "left.htm"> </iframe>
<Iframe id = "right" name = "right" width = "100px" height = "100px;" src = "right.htm"> </iframe>
</Body>
</Html>

Left.htmCopy codeThe Code is as follows: <Head> <title> left </title> <Body>
<Div> I am on the left </div>
<Div> </div>
</Body>
</Html>

Right.htmCopy codeThe Code is as follows: <Head> <title> right </title> <Body>
<Div>
<Input onclick = "onclickRefresh ();" type = "button" value = "Submit"/> </div>
<Script type = "text/javascript">
Function onclickRefresh ()
{
Parent. frames ["left"]. location. reload ();
// Window. left. location. reload ();
}
</Script>
</Body>
</Html>

See right.htm.
Function onclickRefresh () refreshes the left page on the right through parent. frames ["left"]. location. refresh.
If you addCopy codeThe Code is as follows: <div> <input type = "button" onclick = "mainRefresh ();" value = ""/> </div>
<Script type = "text/javascript">
Function mainRefresh ()
{
Window. left. location. reload ();
}
</Script>

You can refresh the subpage on the home page.
Although this can be implemented in a simple way, data in actual projects is not so simple. The most common is the left/right tree, creating and loading a directory tree (for example, creating one thousand nodes) is inherently resource-consuming. If you still need to refresh the Left and Right pages in a way that is less efficient and visible, can you use other methods to achieve cross-origin refresh or commit?
All I think is to use ajax to locally load data. Instead of loading the entire tree. In addition, you can use jquery's json processing method to update local data.
I wonder if there are other more efficient methods? The efficiency of loading trees on 1000 nodes is worth thinking about.

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.