qwert

[Solved] How to clear an embedded IE object?

4 posts in this topic

#1 ·  Posted (edited)

I have an embedded IE object that works fine, when using _IENavigate to display content.  But there are times when I need to clear the content pending the result of other entries or actions.  I've tried navigating to "empty content" by using "" as the URL.  But I get the standard page failed display.

Is there a way to temporarily clear (blank out) the displayed content?

Thanks in advance for any help.

Load Object.PNG

Edited by qwert

Share this post


Link to post
Share on other sites



#2 ·  Posted

On another site, I found a method that seems to work.  If there's a better way, please chime in.

Navigate to blank.PNG

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hi @qwert.

navigating to "about:blank" is one way,

you can also do:

_IEDocWriteHTML($oIE, "")

but doing this does not remove event listeners from the page (like the document events).

Finally you can use HTML in your navigation address, but when i worked with it, it only works in the embedded version:

"about:<!DOCTYPE html><html></html>"

I find the above helpful, as "about:blank" already uses a doctype and i have had little success in changing it, seeing small weird CSS and HTML things that just are a pain in the ass.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for your response.

I've confirmed that both of the "about" methods work.  But I get a consistent failure when trying the WriteHTML method:

Quote

"C:\AutoIt3\Include\IE.au3" (1654) : ==> The requested action with this object has failed.:
$oObject.document.Write($sHTML)
$oObject.document^ ERROR

Nonetheless, the "about:blank" method works better in the context of my particular script.  Yet it's good to know there are other possibilities for placing content in the object.

For now, I'll consider this Solved.

 

Footnote: for the record, I found an example that implies that you must first navigate to the object, and then write any html.  A quick test confirmed that using those two statements does not cause a fail.  This should make it practical to insert text like "Please wait ..." into the object.

I tried the method with the following lines.  It does work.

$sHTML = "<html><body>Hello world</body></html>"
         _IENavigate ($oIE2, "About:Blank")
         _IEDocWriteHTML($oIE2, $sHTML)

 

Edited by qwert

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