Sign in to follow this  
Followers 0
Alamoosook

Problems accessing iFrame - IE version dependent?

7 posts in this topic

Please help with the following problem.

I have written this following script to retrieve data kept in an iFrame (DATA_IFRAME) which is inside a frame (MAIN_FRAME) on page "Data_Page".

#include <IE.au3>
Local $o_ie = _IEAttach("Data Page")
Local $o_frame = _IEFrameGetObjByName($o_ie, "MAIN_FRAME")
Local $o_iframe = _IEFrameGetObjByName($o_frame, "DATA_IFRAME")
$text = _IEBodyReadHTML($o_iframe)
ConsoleWrite($text & @CRLF)

The script which I stripped of all error checking and diagnostics works as it should, but only on my development system running Windows 7 and IE9. It does not work on my production server which runs Windows 2003 and IE8. It also fails if I switch my IE9 into 'compatibility view'.

The script fails on this line:

Local $o_iframe = _IEFrameGetObjByName($o_frame, "DATA_IFRAME")

and produces the following messages:

C:\Program Files (x86)\AutoIt3\Include\IE.au3 (813) : ==> The requested action with this object has failed.:

If $oFrame.name = $s_Name Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_Name))

If $oFrame.name = $s_Name Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_Name)^ ERROR

Examining the HTML as returned from MAIN_FRAME I noticed that if I run IE9 the name value inside the <iframe> tag is in quotes (name="DATA_IFRAME") while under IE8 or IE9cv it is not (name=DATA_IFRAME).

I tried to upgrade IE on the server but IE9 for Windows Server 2003 it is not offered.

Any thoughts?

Thanks in advance.

Share this post


Link to post
Share on other sites



Check a return on Local $o_iframe = _IEFrameGetObjByName($o_frame, "DATA_IFRAME") on windows 2003 and ie9cv to see what u take.

Then if u manage it put an OS check on the top of your script to change the value of $o_iframe depending on the OS ur using it.


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Local $o_iframe = _IEFrameGetObjByName($o_frame, "DATA_IFRAME") does not return anything on IE8 and IE9cv. It crashes inside IE.au3 on line 813. See the error message in my original post. Thanks for looking into this.

Share this post


Link to post
Share on other sites

Add _IEErrorHandlerRegister() before the failure to get more setail on the COM error. I suspect you'll see "Access Is Denied", which indicated a cross-domain security issue.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I have added _IEErrorHandlerRegister() as recommended. This is what I got:

--> COM Error Encountered in test.au3

----> $IEComErrorScriptline = 813

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription =

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

--> IE.au3 V2.4-0 Error from function _IEBodyReadHTML, $_IEStatus_InvalidDataType

When you say that you suspect "Access is Denied" is a problem, do you mean a case where the iFrame data is actually pulled from a different web site than the main page? I do not think this is the case. For this test I actually get the page manually using IE, then when it is already on my desktop I run the script. When the script works (with IE9) it works even if I unplug my network cable! I hope this sheds some light. Thanks for looking into it.

Share this post


Link to post
Share on other sites

With the error handler registered, this error should no longer be fatal to your script. See if you can do more testing, like insuring there are no frames or pages being (re)loaded when you make the initial call, try again after a couple of seconds, etc., try using _IEDocReadHTML to examining page and frame source...

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Dale,

Thanks for your help. I did everything you have told me. Actually in the actual code I do check all return codes and I examine the HTML of each page/frame I am going through. I do not go further if the iFrame tag is not in the HTML. As I mentioned the only difference in the MAIN frame HTML, just before I issue the _IEFrameGetObjByName($o_frame, "DATA_IFRAME") call is that if I run IE9 the name value inside the <iframe> tag is in quotes (name="DATA_IFRAME") while under IE8 or IE9cv it is not (name=DATA_IFRAME).

For now I will use a workaround. Since the data in the frame is displaying in the browser, I just click over the window and then issue ctrl-a, ctrl-c, and I get the data from clipboard. Kind of crude, but works.

I am planning to revisit this later.

Thanks for your support.

Richard

Share this post


Link to post
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
Sign in to follow this  
Followers 0