How do you access the one iFrame on a page when yo

2019-09-06 12:46发布

问题:

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?

回答1:

Try a tag selector

$("iframe")

See Element Selector