让链接在指定的iframe中跳转显示
例子:点击某一个链接,想通过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-->
两种方法效果一样。