How to pass text from one page to another by clicking on div using JQuery/JavaScript

前端 未结 2 533
小蘑菇
小蘑菇 2021-01-15 23:29

I\'m making a school project and i am stuck here for almost a week. what i am trying to get is... I have 2 pages PAGE 1 have more than five divs with different titles. I wan

2条回答
  •  醉酒成梦
    2021-01-16 00:02

    If your pages are hosted by some sort of webserver you can use websockets to communicate/share data.

    If your pages are opened on the same machine/browser without any server i would recommend using the browsers session- or localstorage objects. To set a value use:

    sessionStorage.myValue = 'value'
    

    To get a value use:

    var val = sessionStorage.myValue
    

    Take a look here.

提交回复
热议问题