0

I am trying to reload my web page after window.open('test.com') complete its processing. i have tried following code

try { window.open(scriptURL); //scriptURl is my which i want to open in new window. setTimeout(function () { location.reload(); //It's you code }, 4000); } catch (e) { nlapiLogExecution('error', 'Error requesting SLE', e.getCode() + ' - ' + e.getDetails()); alert('error: ' + e.message); return; } 

The location.reload() is dependent on window.open() once window.open() complete its processing then i want to reload my page.The above code is working fine. But the issue is that if window.open() take more than 4 sec its not work fine. setTimeout is not feasible solution because we are using hardcoded time. So can anyone help me out and come with best solution.

2 Answers 2

0

You can use onload function on your new opened window :

 var openWindow = window.open(scriptURL); //scriptURl is my which i want to openWindow.onload = function(){ location.reload(); //or perhaps openWindow.location.reload(); need to check } 
Sign up to request clarification or add additional context in comments.

Comments

0

You can check if the window finish loading in a couple of ways.

JS

object.addEventListener("load", myScript); 

jQuery

$(window).on('load', function () { }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.