Unable to access data from a child window with https url
I have a simple html file. Using javascript I am opening a https link as a child window. However, if I try to get any data say
var handler = window.open('https://abc.com','newWindow');
var title = handler.window.document.title;
Then it throws an exception saying
Permission denied for http://localhost to get property Window.document from https://abc.com
Can anyone help me out with this. I don't really know if we are allowed to get data like that or not.
Thanks & Best Regar开发者_如何学运维ds.
You are not allowed to access data in this way.
If you are a page on hostname A, you can open windows/frames on hostname B, but cannot in any way interact with them - for security reasons. Otherwise, I could open gmail in an iframe and find out your email address from the window title.
This restriction only applies if window A and window B have different hostnames (this includes protocol, host and port). So if you open iframes/windows on your own domain, this is not a problem.
精彩评论