HTMLView - how to get source

BlitzMax Forums/MaxGUI Module/HTMLView - how to get source

maverick69(Posted 2008) [#1]
How can I get the HTML-Source of a HTMLView Gadget? Is this possible?

Thanks...


skidracer(Posted 2008) [#2]
fortunately it is possible

unfortunately it is a bit ugly involving polling the eventqueue for the result

' htmlview get page source example  
' script sets the window.location which triggers an EVENT_GADGETACTION

' TODO process locations beginning with bod
' TODO provide hooked waitforscript wrapper for ease of use

Strict 

Import maxgui.win32maxguiex

Local window:TGadget
Local htmlview:TGadget

window=CreateWindow("My Window",30,20,600,440,,15|WINDOW_ACCEPTFILES)

htmlview=CreateHTMLView(0,0,ClientWidth(window),ClientHeight(window),window,HTMLVIEW_NONAVIGATE)
SetGadgetLayout htmlview,1,1,1,1 

HtmlViewGo htmlview,"www.google.com"

While WaitEvent()
	Print CurrentEvent.ToString()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_GADGETACTION
			Notify EventText$()
		Case EVENT_GADGETDONE
			HtmlViewRun(htmlview,"window.location=~q/body=~q+document.body.outerHTML")
	End Select
Wend