search

Home  >  Q&A  >  body text

javascript - How do the JS of two pages call each other?

Now there are two pages. I want to click OK on the left page to refresh the right page. These two pages are at the same level. How to implement this?

迷茫迷茫2753 days ago671

reply all(10)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:22:36

    Put this code on the page:

    window.onstorage=function(e){
        location.reload();
    }
    

    aPage code:

    <button onclick="change()">刷新</button>
    
    function change(){
        localStorage.time=new Date().getTime();
    }
    

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:22:36

    If it is two sub-pages under a parent page, it can be achieved

    reply
    0
  • 迷茫

    迷茫2017-05-16 13:22:36

    This should not be possible. I think your requirement should be for the server to actively push messages, such as using websocket

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 13:22:36

    Listening to your expression, it sounds like that. Click on the left menu bar to load the back page.
    A common and simple method is to nest an iframe on the back side. Of course, the other way is to use pajax

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:22:36

    No matter how I think about it, I feel that this is a side navigation, like the one that many people have with a navigation bar on the left or right side of their blog. The other one is the iframe mentioned above. After speaking, the Sheriff returns the votes!

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:22:36

    This doesn’t work. Each page of the browser has a different interface, and it does not provide js with an interface for communication. If two pages need to interact, the most feasible way is websocket.

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 13:22:36

    https://zhuanlan.zhihu.com/p/...

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:22:36

    From what you said, you used the frame code to introduce different pages.
    <FRAMESET cols = "280,*" frameborder=yes bordercolor=silver>

         <FRAME SRC="modifyMenu!showTreeMenu" NAME="menuTree" SCROLLING="No" id="leftTree">  
         <FRAME SRC="showModifyMenu.jsp" NAME="main" SCROLLING="AUTO" id="showModifyMenu">  

    lt;/FRAMESET>

    function init(){

    //leftTree是左边Frame的id  
    //重新加载这个页面  
    window.parent.frames[ "leftTree"].location.reload();  

    }

    You can try this method.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:22:36

    It sounds like a nested iframe page. . .

    reply
    0
  • 迷茫

    迷茫2017-05-16 13:22:36

    两个打开的窗口是两个运行环境吧,这能实现?求大神打脸~

    reply
    0
  • Cancelreply