A JSP page for a.jsp, click a button in a.jsp to open another b.jsp page. Ideas are as follows:
In the event that a.jsp opens b.jsp, write the following code:
| 12 |
window.top[‘_CACHE‘] = chatFrdList; window.top[‘_CACHE‘][frdUserId] = frdUserId; |
Where chatfrdlist is defined as var chatfrdlist = new Object ();
Frduserid is the ID of a user.
So, in an event in b.jsp, you can do the following:
?
| 12 |
<pre name="code" class="javascript" style="margin-top:0px; margin-bottom:0px; padding:0px; font-family:‘courier new‘,courier,monospace">var e = document.getElementsByName("chatWindow");</pre><pre name="code" class="javascript" style="margin-top:0px; margin-bottom:0px; padding:0px; font-family:‘courier new‘,courier,monospace">var keyId = e[0].id; delete window.top[‘_CACHE‘][keyId];// 关闭与该好友的聊天窗口时,将其从聊天表中移除</pre> |
Then, you can operate window.top[' _cache ' in other events in a.jsp, so that you can implement multiple JSP page direct JS object sharing.
Source: Read the answer on the encyclopedia and borrow it for use.
A super method for sharing a JS object with multiple JSP pages