Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is return type of window.open() in Javascript

I am writing code to download a PDF file using window.open(). I am passing the URL path of the pdf file on a server.

window.open(url, name, "width=910,height=750,scrollbars=yes");

I want to check if the downloading of file is successful or not. What is the return type of window.open()?

I tried like this

try
{
  window.open(url, name, "width=910,height=750,scrollbars=yes");
  alert("success");
}
catch(e)
{
  alert("failer");
}

When I change the URL to a wrong URL, it shows the same result as a success.

like image 368
Bhoomin yadav Avatar asked Jul 21 '11 14:07

Bhoomin yadav


1 Answers

http://www.javascripter.net/faq/openinga.htm

The return value is the reference to your new window. You can use this reference later, for example, to close this window (winRef.close()), give focus to the window (winRef.focus()) or perform other window manipulations.

like image 160
Jakub Konecki Avatar answered Nov 13 '22 05:11

Jakub Konecki