In before on foreign domain, I'm trying to access the innerHTML of an iframe that references content that's on the same domain -- but it returns whitespace and no further content [i](e.g. if I use frames[0].document.body.innerHTML (the content references to a PHP file in the same folder via the src attribute))[/i]. It would be greatly appreciated if one could highlight a solution for this [i](apologies if this thread is abundant, but couldn't find anything via a search :/)[/i].
Why would you want to do this?
[editline]a[/editline]
I want to know your motive, this could be used in a few ways.
[QUOTE=sebmck;28083899]Why would you want to do this?
[editline]a[/editline]
I want to know your motive, this could be used in a few ways.[/QUOTE]
It's part of the pre-AJAX method I found -- I can't do anything with the content that's returned from the server unless I can access content of the hidden iframe.
[url]http://www.facepunch.com/threads/1055583-Pre-AJAX-methods-w-PHP[/url]
Because this thread was such a success.
[QUOTE=sebmck;28084079][url]http://www.facepunch.com/threads/1055583-Pre-AJAX-methods-w-PHP[/url]
Because this thread was such a success.[/QUOTE]
Apologies for whatever has been wronged. But can you help me please?
Don't use iframes. It's crap.
Use jQuerys Ajax function to get the data from the page. Then do what ever you need to do with the data. Simple as that.
[QUOTE=Skorpy;28094106]Don't use iframes. It's crap.
Use jQuerys Ajax function to get the data from the page. Then do what ever you need to do with the data. Simple as that.[/QUOTE]
Thanks, but I'd like to understand these techniques too.
[QUOTE=livelonger12;28094353]Thanks, but I'd like to understand these techniques too.[/QUOTE]
I'm not too sure about the parent window accessing the iFrame, but I'm pretty sure the iFrame can access the parent window.
[editline]16th February 2011[/editline]
Basically saying that the javascript on the iFrame can use functions/set variables on its parent.
[editline]16th February 2011[/editline]
Did a quick Google,
document.getElementById("myiFrame").contentWindow.document.body.innerHTML
[QUOTE=deadeye536;28095846]I'm not too sure about the parent window accessing the iFrame, but I'm pretty sure the iFrame can access the parent window.
[editline]16th February 2011[/editline]
Basically saying that the javascript on the iFrame can use functions/set variables on its parent.[/QUOTE]
Thanks. I've tried [code]window.parent.parentNode.nodeValue/innerHTML/whatever;[/code] for the script generated by the server (the server returns a HTML file with a script), but that won't return anything. I also receive the value "null" if I attempt to access the nodeName/value of window.parent.
[editline]16th February 2011[/editline]
Yes! YES! It now works and is awesome! No page refresh FTW!
Sorry, you need to Log In to post a reply to this thread.