HTMLView target?

BlitzMax Forums/BlitzMax GUI Programming/HTMLView target?

How would one go about opening a new target window from a clicked link.

i.e. if you click a link that has target "blank" it normally opens a new browser. Maxgui dosn't seem to be able to do that, even by using HTMLVIEW_NONAVIGATE it dosn't find the target.

Any ideas willbe most welcome :)

Somebody must know, Mark can you help in any way?

It's not exactly ideal, but if they are your web pages you could customize the links by prefixing an identifier, such as "popup:" to URLs that you want to open in a new window, which can then be caught and processed manually using HTMLVIEW_NONAVIGATE... I threw this example together to show you what I mean...

SuperStrict

AppTitle = "Popup Processing Example"

Rem
The idea is that if you want a link to open in a new window, then you need to prefix a link with "popup:", otherwise just leave it like normal.
E.g. If you wanted to open Google in a new window, you'd use something like...

<a href="popup:http://www.google.com/">Google (Opens in a new window)</a>

EndRem

Const strTestHTML$ = 	"<html>~n<head><title>Test Web Page</title></head>~r~n<body>~r~n" + ..
					"<h1>Popup Processing Example</h1>~r~n" + ..
					"<a href=~qhttp://www.google.com/~q>Google (open in embedded htmlview)</a><br />~r~n" + ..
					"<a href=~qpopup:http://www.google.com/~q>Google (open in new window)</a>~r~n</body>"

If Not Confirm("Click OK to write a test HTML file to the following path?~nMake sure that you don't have any valuable data stored there first!~n~n" + AppDir + "/test.htm" ) Then End
SaveText(strTestHTML, AppDir + "/test.htm")

Global wndBrowser:TGadget = CreateWindow("Popup Processing Example", 100, 100, 400, 300, Null, WINDOW_TITLEBAR|WINDOW_RESIZABLE )
	
	Global btnBrowserBack:TGadget = CreateButton("Back",0,0,ClientWidth(wndBrowser)/2,30,wndBrowser,BUTTON_PUSH)
	SetGadgetLayout(btnBrowserBack,EDGE_ALIGNED,EDGE_RELATIVE,EDGE_ALIGNED,EDGE_CENTERED)
	
	Global btnBrowserForward:TGadget = CreateButton("Forward",ClientWidth(wndBrowser)/2,0,ClientWidth(wndBrowser)/2,30,wndBrowser,BUTTON_PUSH)
	SetGadgetLayout(btnBrowserForward,EDGE_RELATIVE,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED)

	Global webBrowser:TGadget = CreateHTMLView(0, 30, ClientWidth(wndBrowser), ClientHeight(wndBrowser)-30, wndBrowser, HTMLVIEW_NONAVIGATE )
	SetGadgetLayout(webBrowser, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED);HtmlViewGo(webBrowser, AppDir + "/test.htm")
	
Repeat

	Select WaitEvent()
		
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE;End
		
		Case EVENT_GADGETACTION
			
			Select EventSource()
				
				Case btnBrowserBack;HtmlViewBack(webBrowser)
				Case btnBrowserForward;HtmlViewForward(webBrowser)
				
				Case webBrowser
				
					Local tmpRequestedURL$ = EventText()		'Get the string of the requested URL
					
					Local tmpProtocols$[] = tmpRequestedUrl.Split(":")		'Let's split the string so we can check what the first "protocol" is
					
					If tmpProtocols.length > 1 And tmpProtocols[0].ToLower$() = "popup" Then	'If we have a protocol and it is our custom "popup" one...
						
															'Let's open the URL in the default OS browser, 
						OpenURL(":".Join(tmpProtocols[1..]))		'Remember, we need to strip the 'popup' prefix from the array as ordinary browsers won't understand "popup:"...
						
					Else
						
						HtmlViewGo(TGadget(EventSource()), tmpRequestedURL)	'Otherwise, we'll just use navigate to it in the current HTML View object.
						
					EndIf
			
			EndSelect
			
	EndSelect

Forever


Thanks for your post SebHoll but i dont think its ideal either i want to stay away from popups ect. cheers anyway.

Hopefully Mark will have an idea :) nudge nudge.