Reputation: 55
Working Code
assuming you have a page with two different iframe where the first menu and the second container of the selected page.
how can I at the click of a link in the menu frame display the selected page iframe container?
In menu page i have this
...
</li>
<li class="title"><a href='javascript:parent.document.getElementById("frame").src = "pages/setting.php"'><?php echo $lang['MENU_IMPOSTAZIONI']; ?></a>
<img src="images/bullet_arrow_down.png" /></li>
<li class="sub-menu">
<ul>
...
in index this:
...
<iframe id="menufrm" src="menu.php" width="250px" height="700px" frameborder="none"></iframe>
<iframe name="frame" src="" width="99%" height="99%" frameborder="none"></iframe>
...
But with this, when i click in the button in menu the page is displayed correctly in container, but menu.php disappears and in its place appears a string with relative path of the document displayed in iframe.
how to fix it?
Upvotes: 2
Views: 5542
Reputation: 2563
'The best solution is probably to use a target on your <a>
element.
Alternatively you can use javascript this way:
<a href="javascript:void(0)" onclick="parent.document.getElementById('frame').src = 'pages/setting.php'">...
Upvotes: 1
Reputation: 36
<iframe src="frame1.html" name="myFrame">
<a href="frame2.html" target="myFrame">
Upvotes: 2