Adding code to parent from within iframe?

Adding code to parent from within iframe?

I'm not sure if this is something that it makes sense to use jQuery for or whether I can just use a bit of javascript to achieve the same thing, or whether it can be done at all. I've spent quite some time trying to understand the issue but have very little javascript or jQuery knowledge so hoping someone can help me out.

What I want to be able to from within an iframe is:


check if

parent.window.document.getElementById("autoloadpop") is null

and if so I want to add:

<a href='popup.php' id='autoloadpop' onclick="return hs.htmlExpand(this, { contentId: 'popup', objectType: 'iframe', width: 620, maxHeight: 400} )"></a>

to

<div id='main-header'> within the parent page

and then make the following call:

parent.window.document.getElementById('autoloadpop').onclick();


Any help would be greatly appreciated.