Reputation: 6347
I am trying to fill a textarea in a window opened with open(link_here)
(on the same domain). It works fine in all browsers except IE/Edge.
Steps to reproduce here on stackoverflow:
var w = open('https://stackoverflow.com'); // example
// (allow popups and) wait for window to be opened, then:
let input = w.document.getElementsByClassName('f-input js-search-field')[0]
const prototype = Object.getPrototypeOf(input); // returns null on IE/Edge
Any workaround? Thanks
Upvotes: 0
Views: 158
Reputation: 42736
I believe it is a Hierarchy access restriction. Since the element is not in the same window
as the Object
you are using, it doesn't have access to the object's information. You will have a somewhat similar problem if you try to append an element created by the main document and try to append it to the iframe document. When attempting this you will get a HierarchyRequestError
.
Instead of using the main window
's Object
use the iframe window
's Object
:
var prototype = w.window.Object.getPrototypeOf(input);
console.log(prototype);
Upvotes: 1
Reputation: 72
instead of vanilla javascript try JQUERY which works on every browser correct so change your selector to jquery one you need to include first JQUERY at your file
Upvotes: 1