-1

I want to load a webpage http://localhost/12.13.12.56.

I'm returning this content which should close this tab:

<html><head>
<script>
 window.load=function(){ window.close();}
</script> 
</head>
<body></body>
</html>

But the Google Chrome console is showing this error:

Scripts may close only the windows that were opened by it.

After loading of this url I want to close it automatically. How can I do that?

sri harsha
  • 676
  • 6
  • 16
user5858
  • 1,082
  • 4
  • 39
  • 79

1 Answers1

0

It means, The window.close() function will work only for the tabs, Which is opened by your script OR opened from your page.

something like,

var w = window.open('location','_blank');
w.close();

Attempting to close tab while loading it is a bad idea. Why you want to do that?

BadPiggie
  • 5,471
  • 1
  • 14
  • 28
  • I'll click ipaddress in google sheet which will open this url http://localhost/12.13.12.56 will call a local webserver, which will automatically start the tightvnc viewer withthis ip address. Just for automation – user5858 Feb 06 '19 at 09:06