Answered by:
extracting the innerHTML from an iFrame's < body >

Question
-
Hello,
I would like to know if my JS code would somehow able to exctract the innerHTML from an iFrame (from its <body>) put on the UI.
Thanks in advance
Monday, October 22, 2012 8:24 AM
Answers
-
Hi,
Firstly, you could get the sourcecode with winjs.xhr.
Secondly, you could use regular expressions to get the innerHTML from <body>.
#WinJS.xhr function
http://msdn.microsoft.com/en-us/library/windows/apps/br229787.aspx
#Regex Tutorial
http://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework- Marked as answer by Song Tian Friday, November 9, 2012 6:19 AM
Tuesday, October 23, 2012 3:00 AM
All replies
-
Hi,
Firstly, you could get the sourcecode with winjs.xhr.
Secondly, you could use regular expressions to get the innerHTML from <body>.
#WinJS.xhr function
http://msdn.microsoft.com/en-us/library/windows/apps/br229787.aspx
#Regex Tutorial
http://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework- Marked as answer by Song Tian Friday, November 9, 2012 6:19 AM
Tuesday, October 23, 2012 3:00 AM -
Thanks for the reply but my question does not mention where the iFrame loads its content from, so I mean extracting the HTML from the inside of the iFrame. In my case the iFrame loads a local HTML file that was copied inside the private app folders on behalf of the user.Tuesday, October 23, 2012 7:44 AM
-
Hi,
Anyway, you need to request the iframe page firstly. And extract the html content later.
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code FrameworkThursday, October 25, 2012 6:30 AM -
To load the page in the iFrame the src attribute has to be set, so xhr is not useful because the page is not requested, it is loaded from disk. I often experienced the DOM document of the iFrame being not accessible when a local html is involved (Chrome, for example).
Thursday, October 25, 2012 8:07 AM