Reputation: 657
I have a code like this:
parent.document.getElementById("test").value ="1";
but it doesnt work on chrome. The error is:
"Uncaught TypeError: Cannot call method 'getElementById' of undefined"
any help is apreciated thanks in advance! :)
Upvotes: 1
Views: 1177
Reputation: 2669
Well, this is strange. Because your code should work. I even tested it now to be sure. So somehow your parent
isn't the window
object. That's why it has no document
property.
The global parent
is the parent property of the window
object (window.parent
) which usually points to the window
object itself . So usually parent
and window
are the same thing and you don't even have to use this object explicitly most of the time.
So my guess is that you've somehow overwritten parent
with some other object.
Edit: My second guess is that you haven't overwritten parent yourself but have embedded the window into another window. So your parent becomes this outer window and you probably don't have access to its document.
Upvotes: 1
Reputation: 35276
document.getElementById("test").value ="1";
parent of the scope (window) is null
Upvotes: 3