当您不知道名称或ID时,如何访问页面上的一个iFrame? [英] How do you access the one iFrame on a page when you don't know the name or ID?

查看:357
本文介绍了当您不知道名称或ID时,如何访问页面上的一个iFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个html页面:

 < iframe frameborder =0allowtransparency =truetabindex =0 src =
title =Rich text editor,editor_kama,press ALT 0 for help。
style =width:100%; height:100%;>
< html>
< body>< p> replace me< / p>< / body>
< / html>
< / iframe>

如何访问iFrame,假设我不能给iFrame一个名称或ID,因为它动态并假设页面上始终只有一个iFrame?



我想能够将iFrame中的body标签中的所有内容替换为found

解决方案

任何想法?

尝试标记选择器

  $(iframe)

请参阅 元素选择器


Given an html page with:

<iframe frameborder="0" allowtransparency="true" tabindex="0" src="" 
        title="Rich text editor, editor_kama, press ALT 0 for help." 
        style="width: 100%; height: 100%;">
  <html>
    <body><p>replace me</p></body>
  </html>
</iframe>

How can I access the iFrame assuming I can't give the iFrame a name or ID since it's made dynamically and also assuming that there is always only one iFrame on the page?

I'd like to be able to replace everything in the body tag within the iFrame with "found me" or something like that.

Any ideas?

解决方案

Try a tag selector

$("iframe")

See Element Selector

这篇关于当您不知道名称或ID时,如何访问页面上的一个iFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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