Causes and solutions for the unexecuted window. location event on the page, window. location

Source: Internet
Author: User

Causes and solutions for the unexecuted window. location event on the page, window. location

1. Problem description:

Widow. location = function () defined in JS. When the page is closed, the logout () function is not executed.

window.onunload = function() {logout();}function logout(reqParam, callback){var userManageServiceUrl = "http://" + getServerAddr() + "/axis2/services/UserManageService";var urlList = [];var url = window.location.href;urlList = url.split("?");var sessionID = urlList[1];reqParam.sessionID = sessionID;var pl = new SOAPClientParameters();var reqParamStr = JSON.stringify(reqParam);pl.add("reqParam", reqParamStr);SOAPClient.invoke(userManageServiceUrl, "logout", pl, false, callback);}

2. cause:

Call SOAPClient in logout. invoke () method. The parameter is true, indicating that the frontend and server communicate asynchronously. That is, the frontend has executed the following statement before receiving the response from the server, in this case, when the front-end executes logout (), the page is closed before the server responds. Therefore, logout () is not executed.

3. solution:

Change the communication mode between the frontend and the server to synchronization, and change "true" to "false" in the SOAPClient. invoke () method to solve the problem.


Why does windowlocation not be executed in js?

1 --
Determine if your system has disabled JS running

2 --
Check whether the code is executed.

3 --
Check whether the code is correct. The answer is to provide you with a check plan:

Modify window. location = '...' to three rows: the answer is faster and depressing.

To:

Alert ("before window. location set ");
Window. location = '...';
Alert ("after window. location set ");

This is the method I usually detect javascript. If the first alert is not called, move it forward until the first call, then confirm the error and fix it.

In addition, if you give window. the location value is the address of the current page, and this change is invalid (because only the location change will be executed, and the value you set is not changed, so it will not be executed ).

If you want to refresh the current page, it seems that location has a refresh function or something similar (the specific function or object is missing ). Check your location spelling.

Usage:

Alert (window. location)

The displayed information should be the current url address.

Why does windowlocation not be executed in js?

Then try:
Window. location. herf = "";
Check whether the task can be executed. Otherwise, use Navgate to navigate to a page!
 

Related Article

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.