Jump to content

Why _IEDocReadHTML can't retrieve DOM source of iFrames?


Recommended Posts

Hello, I'm having a HTML file in my computer. It only contains an iFrame and I use _IECreateEmbedded to load it within my AutoIT program.

<html><body><iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.com"></iframe></body></html>

I try to use _IEDocReadHTML but this function can't retrive the DOM source for my local file. It returns the same thing above.

_IENavigate ($oIE, "file:///C:/test.html")
$sHTML = _IEDocReadHTML($oIE)
MsgBox(4096, "", $sHTML)

So can anybody help me please? :idea:

Edited by Bot
Link to comment
Share on other sites

Uhmmm... what did you want it to return?

You get exactly the same with just IE:

#Include <IE.au3>

Global $sFile, $sURL, $oIE, $sHTML

$sFile = @ScriptDir & "\Test1.html"
$sURL = "file:////" & StringReplace($sFile, "\", "/")

$oIE = _IECreate($sURL)
$sHTML = _IEDocReadHTML($oIE)
ConsoleWrite("HTML:  " & $sHTML & @LF)

Were you expecting the www.google.com source to show up inside the frame?

:idea:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Edit (3) : Neither IE nor FF can retrieve the DOM source of iFrames in both remote and local files. So I'm stuck now. Maybe I should find other solution. I'm still wonder how the FireBug extension of FF can get the DOM source of iFrames? Edited by Bot
Link to comment
Share on other sites

Cross-site scripting protections are preventing what you want to do:

#Include <IE.au3>

_IEErrorHandlerRegister()

Global $sFile, $sURL, $oIE, $sHTML

$sFile = @ScriptDir & "\Test1.html"
$sURL = "file:////" & StringReplace($sFile, "\", "/")

$oIE = _IECreate($sURL)
$sHTML = _IEDocReadHTML($oIE)
ConsoleWrite("HTML (Parent):  " & $sHTML & @LF)

$oFrame = _IEFrameGetCollection($oIE, 0)
$sHTML = _IEDocReadHTML($oFrame)
ConsoleWrite("HTML (Frame):  " & $sHTML & @LF)

Note errors:

----> $IEComErrorWinDescription = Access is denied.
----> $IEComErrorDescription = Access is denied.

You need to load the site from the frame into its own instance of IE and work with that.

:idea:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...