Open a link from iframe to be opened in the main window

Viewed 40

My site has 3 frames: leftframe, maincontent, and rightframe. In the right one, I put an iframe called "online". Inside of it, there is a link that should open a modal-content in the mainframe. Here's the problem! If I leave the iframe, the modal doesn't open. If I erased the iframe, the modal works.

How can I open this link from "online" iframe to the main window (#maincontent)?

This is the link I have inside online iframe and that supposed to be opened in #maincontent (so, outside the iframe on the right frame)

var modal = document.getElementById('id01');

window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}

function changeFrame(input_text) {
  document.getElementById("myframe").src = input_text;
}
<a href="#" onclick="changeFrame('pages/msg/new_text.php?reply_dest=<?php echo $record['name']; ?>');document.getElementById('id01').style.display='block';">LINK</a>

1 Answers

Try this:

<a href="#" target="_parent">Link Text</a>

The target="_parent" attribute opens the link in the parent frame which will be the main window in your case.

Related