How to pass javascript object from one page to other

前端 未结 7 1651
时光说笑
时光说笑 2020-11-27 07:27

I want to pass javascript object from one page to other page so anyone can tell me how to do it?

Is that possible to do so using jQuery?

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 07:29

    That is only possible if the pages exist at the same time, and one page is opened from the other so that you have a reference to the other pages windows object.

    If you navigate from one page to another, they don't exist at the same time, so you can't communicate like that. You would have to serialise the object into a string that you can send along in the request, for example sending JSON in the query string.

    There are different ways of persisting data, like in the query string, post data, cookies, window name or HTML5 local storage, but all those methods can only persist string values, not Javascript objects.

提交回复
热议问题