Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have an iframe with a website inside it. I want that when a person clicks on a link inside the iframe a new window should open up bringing the user to the page in the website (that was in the iframe) that they were trying to go to. I hope I am being clear. Thanks so much (in advance) for all the help.
Posted
Comments
Yusuf 9-Feb-11 16:02pm    
Please don't put comment as Answer. I've deleted your 'Answer' which is the same as the comment below.

1 solution

set the link's target to target="_blank"


<a href="http://www.codeproject.com/" target="_blank">Open In New Window</a>
 
Share this answer
 
Comments
readbanana 9-Feb-11 15:54pm    
I don't have access to the links.
Yusuf 9-Feb-11 16:02pm    
If you don't have an access to the pages, I am not sure how much you can do. You can try to attach onclick event on the frame it self and try to intercept them, but I am not sure if this will work.

document.getElementById('ifrm').contentWindow.document.body.onclick=function(){ //put your code here }

You need to write code in the function and 'ifrm' is your iframe ID
readbanana 9-Feb-11 16:07pm    
onclick is not valid for an iframe. I was wondering if it would even be possible for me to do this! If anyone knows that I can I would really appreciate it. Thanks for trying, Yusuf!
Yusuf 9-Feb-11 16:30pm    
would this help you
http://stackoverflow.com/questions/2381336/detect-click-into-iframe-using-javascript
readbanana 9-Feb-11 16:32pm    
That wouldn't have the effect that I want. I may fall back on this if I can't work it out. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900