0

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

asked Dec 17, 2012 at 17:20
1
  • 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. Commented Oct 6, 2014 at 2:39

3 Answers 3

1

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

answered Dec 17, 2012 at 18:49
Sign up to request clarification or add additional context in comments.

3 Comments

True, that works but if you would click on that link for the second time it will open in a new browser tab (by the way the only browser where it doesn't do this is Mozilla Firefox)
im testing it on chrome and it doesnt open in a new window the second click. if this approach doesnt work on moz however (havent checked), you may have to resort to a js solution.
in youre code: <a href = "last.fm/music/The+Beatles/Abbey+Road" target="_parent" name="right_frame">Abbey Road</a> the link needs to have target set to right_frame not name! your target is set to parent, which, i believe is only used in your grandparents framesets. fix and try again, maybe it works afterall?
0

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;
 }
}
answered Dec 17, 2012 at 17:56

5 Comments

Thanks for your feedback but I really need this to work with iFrames.. I know it's not really a good way but I'd like to find a working solution for iFrames. Thanks
@Peacy Don't really feel like the answer deserves a -1. It's a correct answer, just doesn't apply to your specific situation and it was only a suggestion of another way. But I will try to work on another solution for you using iFrames in the meantime.
I do appreciate your answer and I'm open to any kind of suggestion but I didn't gave you that -1, it was already there when I read the comment. Thanks for your effort in this, gave it a +1 so now it's equal to 0
@Peacy Ahh, sorry for the mis-interpretation... No worries. I'm working on a solution for you.
@Peacy May I ask why you are using iFrames over other methods? I'm not sure if the elements of index.html can be accessed from left-side.html as they are considered two separate pages by the browser (I believe). And I think the target="_Parent" only tells the window (tab) to open the element.
0

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

answered Dec 17, 2012 at 19:28

1 Comment

This doesn't seem to answer the original question.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.