Cheap VPS host selection
Provide server host evaluation information

Window.location.href What to do after opening a new window

When you open a new window using window.location.href, you can use JavaScript to operate the window.

If you want to perform some operations in a new window, you can use the following code:

window.open(‘ http://www.cnraksmart.com ’, ‘_blank’);

The above code will open a new window or tab and open the specified URL in it( http://www.cnraksmart.com )。_ Blank is a special window name that represents the URL to open in a new window or tab.

If you need to perform some operations after opening a new window, you can set a callback function before opening a new window. For example:

window.open(‘ http://www.cnraksmart.com ’, ‘_blank’, ‘location=yes, height=500,width=500,scrollbars=yes’);

//Wait for the new window to load and perform some operations
window.onload = function() {
//Write the code to be executed after the new window is loaded here
};

The above code will open a new window in which the specified URL will be opened. Then, use the window.onload event listener to wait for the new window to finish loading, and execute the corresponding operation after loading.

Please note that due to the browser's security restrictions, you may not be able to perform some operations in the new window, especially those related to cross domain operations. Therefore, please ensure that your code complies with the browser's security policy.

Do not reprint without permission: Cheap VPS evaluation » Window.location.href What to do after opening a new window