在 iframe 中打开链接 [英] open link in iframe

查看:129
本文介绍了在 iframe 中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有框架的页面,框架下方还有一些链接.

I have a page with a frame in it, and some links below the frame.

我希望链接在点击时打开框架中的页面.

I want the links, when clicked, to open the page in the frame.

我试过<a href="" target="nameofframe">link1</a>但是没有用?

更新它是一个 iframe.

update its an iframe.

推荐答案

假设 iFrame 有一个 name 属性为myIframe":

Assuming the iFrame has a name attribute of "myIframe":

<a href="http://www.google.com" target="myIframe">Link Text</a> 

您也可以使用 Javascript 来完成此操作.iFrame 有一个 src 属性,用于指定它显示的位置.因此,将链接的单击绑定到更改该 src 属性是一件简单的事情.

You can also accomplish this with the use of Javascript. The iFrame has a src attribute which specifies the location it shows. As such, it's a simple matter of binding the click of a link to changing that src attribute.

这篇关于在 iframe 中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆