JavaScript Window.Open - window opens behind current window

I have a Client Script - JScript assigned to a button in my app. When the button is clicked the window opens in a new browser window, but it opens behind the current window. We have to minimize the browser app in order to see the window opened from window.open. How can I revise the code below to open the window in front of the app window? Thanks!
function AppraisalClick() {
  window.open("\\\\ops047-mw1\\MLCommon2\\Appraisals\\"+document.all.LoanNumber1.value
+".pdf", "_blank");
}

Open in new window

LVL 2
asmyattAsked:
Who is Participating?
 
hieloCommented:
try:
function AppraisalClick() {
  var child = window.open("\\\\ops047-mw1\\MLCommon2\\Appraisals\\"+document.all.LoanNumber1.value
+".pdf", "_blank");

setTimeout(function(){child.focus();},250);
}
0
 
asmyattAuthor Commented:
It still opened behind the current app window.
0
 
leakim971PluritechnicianCommented:
How do you open it ?

What about the following :

(wait for 10 seconds and don't touch anything on my computer before ! :)


function AppraisalClick() {
  var child = window.open("\\\\ops047-mw1\\MLCommon2\\Appraisals\\"+document.all.LoanNumber1.value+".pdf", "_blank");

setTimeout(function(){child.focus();},10000);
}

Open in new window

0
 
hieloCommented:
>>It still opened behind the current app window.
The code I gave you above should work. It simply delays focusing by 250 milliseconds (quarter second - Thus if you were to use 1000, you are essentially delaying by ONE second). If anything you may need to play with that number, depending on how long your largest document takes to load.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.