Ok so the problem is that when you click on a link in the left iframe I'd like it to open in the right iframe. When you click on a link in the left sidebar for the first time this all works great. But when you would click for the second time on that link (in the left sidebar) it will open in a new browser tab. How can I make it work that it will open constantly in the right frame?.
Thanks in advance, Peacy
index.html http://pastebin.com/u6DqDA1q
left_frame.html http://pastebin.com/UuZYtdYs
-
If any of the below answers presented a solution to your question, please accept their answer by clicking on the check mark beside their answer. This will help future users searching for an answer to the same question. Thank you.SnareChops– SnareChops2014年10月06日 02:39:32 +00:00Commented Oct 6, 2014 at 2:39
3 Answers 3
Yes, it should work just fine, the link in iframe 1 needs to have target equal to the name of the target iframe.
For example:
Iframe 1
<iframe src=""></iframe>
Target Iframe
<iframe name="iframe2"></iframe>
Content of Iframe 1
<a href="" target="iframe2">Link opens in iframe 2</a>
Also check this link i found
http://www.trans4mind.com/personal_development/HTMLGuide/iframes3.htm
3 Comments
Have you considered using AJAX to populate div's for the other side? This would help with platform compatibility as-well
<div id="left-side"></div>
<div id="right-side"></div>
left.html
<a onclick="OpenToRightSide('some-url')">some url text</a>
and in the main html parent file
function OpenToRightSide(url)
{
var xmlhttp;
if (window.XMLHttpRequest)xmlhttp=new XMLHttpRequest();
else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",url,true);
xmlhttp.send();
xmlhttp.onreadystatechange=function()
{
document.getElementById("right-side").innerHTML=xmlhttp.responseText;
}
}
5 Comments
target="_Parent" only tells the window (tab) to open the element.I come to the same conclusion that it doesn't work the second time you click on the link. I'm not sure what the problem is, but here is the code for the 2 files, based on the suggestions by user1721135. http://pastebin.com/B2F2XseH and http://pastebin.com/6nZBXEU1