0

我问这个是因为我想在 iframe 中显示一个页面,并且在单击 iframe 内容中的任何链接时,它应该在同一个 iframe 中显示它。

检查这个网站。看看 iframe 如何让我浏览其他网站。

4

2 回答 2

1

这没什么特别的,这就是 iframe 的工作方式。

但是,如果这些网站中的任何一个有

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

它将脱离 iframe 并加载到主页中。

我知道无法阻止 iframe 使用 target=_top 链接接管您的窗口。您不能从父窗口修改 iframe 中其他人的内容,谈论交叉框架存在安全问题,阻止您这样做。

使用Thickbox 只需加载您的html 文件并确保您不要在任何要保留在iframe 中的thage 页面中定位=_top。

因此,使用一些 jQuery 从ThickBox 的示例中复制和粘贴:

<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>  
于 2009-04-25T12:22:26.773 回答
0

Facebox插件将以厚盒方式拉入远程页面。

于 2009-04-25T12:37:53.757 回答