views:

518

answers:

2

I ask this because I want to display a page in iframe and on clicking any link in iframe content, it should display it in the same iframe.

Check this site. and see how an iframe alow me to surf other sites.

+1  A: 

that's not anything special, that's just how iframes work.

however if any of those sites had an

<a href="LINK" target="_top">text</a>

It would break out of the iframe and load in the main page.

There is no way that I am aware of to stop an iframe from taking over your window with target=_top links. You can't modify someone else's content in the iframe from your parent window, there are security issues with talking cross frame that prevent you from doing this.

With Thickbox just load your html file and make sure you dont target=_top in any of thage pages you want to stay in the iframe.

So copy & pasting from ThickBox's example, with some jQuery:

<script>
  var height = 300;
  var width  = 300;
  $(function(){
     $("#execute").click(function(){
         $("#link1").attr('href',$('#go').val() + "?height=" + height *"&width=" + width).trigger('click');
     });
  });
</script>

<input type="text" name="go" id="go" />
<button id="execute">Go >></button>

<a id="link1" href="ajaxOverFlow.html?height=300&width=300" title="add a caption to title attribute / or leave blank" class="thickbox">Scrolling content</a>
Chad Grant
A: 

The Facebox plugin will pull in remote pages in a Thickbox way.

RedWolves