Jump to content

[Solved] How to clear an embedded IE object?


qwert
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
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...