简体   繁体   中英

How do I get links that are AJAXy to replace the content inside an iFrame?

So, I added to my AJAX links the name of the iframe, target="name" , but I think I might be erroring on the replacing part...

page.replace_html("section-content",:partial=>"/path/contents/edit",:object=>@content)

yeah, it's RoR, but that's not important... I think my selector isn't being found because that div is now in an iframe.

How to I select elements in an iframe?

I've tried window.frames['name'].document but I just get a document object that seems to have no methods.

window.frames['name'].contentDocument.document

Note: You must obey the same-origin policy.

For IE7 and lower, use:

window.frames['name'].contentWindow.document

PS, you can use document.getElementById('id') instead of window.frames['name']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM