What is the return type of window.open () in Javascript

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

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

I want to check if the file was uploaded successfully. What is the return type 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 the wrong URL, it shows the same result as success.

+5
source share
2 answers

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

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

+7
source

Window.open , , . html- ( ),

var newWin = window.open();
if(newWin == null) {
  alert("darn");
}
newWin.document.getElementById("anElement").innerText = "Fish";
+4

All Articles