A super method for sharing a JS object with multiple JSP pages

Source: Internet
Author: User

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

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.