Jump to content

Recommended Posts

Posted (edited)

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
Posted

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
Posted (edited)
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
Posted

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
Posted
Ok I see. Then I will parse the URL of the iFrame and deal with it. Anyway thanks so much for your help.

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
×
×
  • Create New...