Q_24652789: Cross frame scripting example

This example shows how you can click on a link that makes an element in another frame visible or invisible (toggles).

This page will remain online for future reference. The original question can be viewed at Experts-Exchange, but requires (free) membership. More information about me, about how this site is maintained and about how to use these pages for yourself, check out the opening page.

Try DEMO

Use the following code:

<script type="text/javascript>
    function toggleLogin(){
        var divElem = parent.mainFrame.document.getElementById('LoginID');
        if(divElem) {
            divElem.style.visibility = divElem.style.visibility == "hidden" ? "visible" : "hidden";
        } else {
            alert("No element found with id 'LoginID'");
        }
        return false;
    }
</script>

<-- example href as used above -->
<a href="." onclick="return toggleLogin();" >Try DEMO>/a>