HeidiR Posted December 10, 2008 Posted December 10, 2008 Hi All, I'm trying to display some HTML in an IE object. I am able to successfully display google.com in the control but not some local html from a variable. Code below. Is this possible? CODE;Define $oIE = ObjCreate("Shell.Explorer.2") GUICtrlCreateObj($oIE, 1, 1, 500, 500) ;This works $oIE.navigate("http://www.google.com") ;This does not work (page can not be displayed) $html = "<html><head></head><body><b>test</b></body></html>" $oIE.navigate($html) HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Josbe Posted December 10, 2008 Posted December 10, 2008 Hi All,I'm trying to display some HTML in an IE object. I am able to successfully display google.com in the control but not some local html from a variable. Code below. Is this possible? CODE;Define$oIE = ObjCreate("Shell.Explorer.2")GUICtrlCreateObj($oIE, 1, 1, 500, 500) ;This works$oIE.navigate("http://www.google.com");This does not work (page can not be displayed)$html = "<html><head></head><body><b>test</b></body></html>"$oIE.navigate($html)AFAIK, the parameter must be a document/link not HTML code. Save the file first and link it. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
HeidiR Posted December 10, 2008 Author Posted December 10, 2008 AFAIK, the parameter must be a document/link not HTML code. Save the file first and link it.Thanks for the quick reply. Is there a way to display HTML code from a variable in Autoit without using an external html file? HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Rental Posted December 11, 2008 Posted December 11, 2008 here the code from the help file that I modified to get it to work. expandcollapse popup#include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister () $sHTML = "<h1>Hello World!</h1>" $oIE = _IECreateEmbedded () GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360) $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) GUISetState() ;Show GUI _IENavigate ($oIE, "") _IEBodyWriteHTML ($oIE, $sHTML) ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate ($oIE, $sHTML) Case $msg = $GUI_Button_Back _IEAction ($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction ($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction ($oIE, "stop") EndSelect WEnd GUIDelete() Exit
DaleHohm Posted December 11, 2008 Posted December 11, 2008 See _IEDocWriteHTML 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
HeidiR Posted December 11, 2008 Author Posted December 11, 2008 here the code from the help file that I modified to get it to work. expandcollapse popup#include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister () $sHTML = "<h1>Hello World!</h1>" $oIE = _IECreateEmbedded () GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360) $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) GUISetState() ;Show GUI _IENavigate ($oIE, "") _IEBodyWriteHTML ($oIE, $sHTML) ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate ($oIE, $sHTML) Case $msg = $GUI_Button_Back _IEAction ($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction ($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction ($oIE, "stop") EndSelect WEnd GUIDelete() Exit Thanks for your help Rental. I got it to work with your code! HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
HeidiR Posted December 11, 2008 Author Posted December 11, 2008 See _IEDocWriteHTMLDaleThanks DaleHohm. This looks helpful. I think I have two solutions now! HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
OregonJohn Posted June 25, 2012 Posted June 25, 2012 Thanks HeidiR, I needed to not use IE.au3 because it wouldn't get past the obfuscator. Then I saw your post and saw I didn't even need it. Mostly, I just want to have some nice html displayed instead of extended labels to explain how to do something. So I wrote an html file that goes along with the script. It could be a local file or a web page, but here's how I made it work for me: #include $HTML = "http://google.com" GUICreate("Test html", 400, 410) ;Create frame for html to show Local $oIE = ObjCreate("Shell.Explorer.2") GUICtrlCreateObj($oIE, 10, 10, 380, 280) $oIE.navigate($HTML) ;End create frame for html to show GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete()
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now