For example:
$(elementid,top.document).attr(attributeName)
or
$(elementid,parent.document).attr(attributeName)
works in IE or Chrome but doesn't work in Firefox.
Does anyone know what the firefox equivalence is?
Thanks!
When a page is running inside of an iframe, the parent object is different than the window object. You can still access parent from within an iframe even though you can't access anything useful on it. This code will never cause an error even when crossing origins.
jQuery parent() Method The parent() method returns the direct parent element of the selected element. The DOM tree: This method only traverse a single level up the DOM tree.
To access elements of parent window from iframe with JavaScript, we can use the window. parent. document property to get the parent window's document.
You can use jQuery to add jQuery effects to your iFrame elements, to change the CSS rules, or even to add content. Above, the script is used to change the background color of the . page element within the frame to white.
What about:
window.parent.$(elementid).attr(attributeName);
Try this:
$("#myid", top.document);
or
$("#myid", parent.document.body);
Ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With