分享好友 教程首页 教程搜索 频道列表

让链接在指定的iframe中跳转显示

2018-09-02 10:105200
+关注28
核心提示:点击某一个链接,想通过js代码跳转到父页面的某个iframe中,实现不刷新父页面在ifr...

例子:点击某一个链接,想通过js代码跳转到父页面的某个iframe中,实现不刷新父页面在iframe中显示链接内容

<a>显示内容</a>

<iframe frameborder="0" width="100%" height="100%" name="showList" scrolling="auto" style="background-color:transparent"> </iframe>
<!--该iframe的name值为showList-->

<script>
$("a").click(function() {
window.showList.location.href = "http://www.baidu.com"; //showList是指定的iframe的name
})
</script>
这种方式与不写js方式类似,就是指定a标签的target和href

<a href="http://www.baidu.com" target="showList">显示内容</a>
<iframe frameborder="0" width="100%" height="100%" name="showList" scrolling="auto" style="background-color:transparent" >
</iframe><!--该iframe的name值为showList-->
两种方法效果一样。

本文标签: #iframe #js
整理员:小黑
免责声明:凡注明来源本网的所有作品,均为本网合法拥有版权或有权使用的作品,欢迎转载,注明出处。非本网作品均来自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。
生成海报
您可能在找更多

iframe自适应高度(随内容高度变化)

    iframe自适应高度

网络转载 JS相关2021-12-04

iframe自适应屏幕高度

    这个需求一般用于移动端htmliframeid=idididsrc=https://hao.360.cn/iframeJS部分scripttype=text/javascriptfunctionautoHeight(){if(window.innerHeight){//FFnowHeight=window.innerHeight;}else{nowHeight=docum

小黑 web前端开发2021-08-12

X-Frame-Options的nginx配置

    X-Frame-Options头主要是为了防止站点被别人劫持,iframe引入nginx配置形式:add_header X-Frame-Options ALLOWALL; #允许所有域名iframeadd_header X-Frame-Options DENY; #不允许任何域名iframe,包括相同的域名add_header X-Frame-Options SANEORIGIN; #允许相同域名iframe,如a.test.com允许b.test.comadd_header X-Frame-Option

小黑 linux2019-08-19

下一篇
我来说两句
抢沙发