How can I stop external links??

BlitzPlus Forums/BlitzPlus Beginners Area/How can I stop external links??

Seldon(Posted 2005) [#1]
I've made a simple browser using the Blitz' HTML commands, but I would like to stop some links opening a page on a new Internet-Explorer window. Is that possible in some way ? Thanks for any help.


Beaker(Posted 2005) [#2]
This should do what you want:
html=CreateHtmlView( 0,45,ClientWidth(window),ClientHeight(window),window, 3 ) ; note the style flag at the end

..but it doesn't fully unfortunately. I take this to be a bug in B+, so let me know how you get on.

You should be able to use that in conjunction with HtmlViewEventURL.


Seldon(Posted 2005) [#3]
Thanks for your time. Yes, with style flag 3 (1+2) you stop the right mouse button (flag 1) and you've a direct control over links (flag 2) , but it doesn't stop the opening of links in a new window.

I found a solution though.

I use these few lines:
Const WM_CLOSE=16
hWnd=FindWindow_NameNull("IEFrame",0)
If hWnd
 PostMessage(hWnd,WM_CLOSE,0,0)
EndIf

They must be executed for some time after a new link is pressed by the user. If a new "IE" window is opening, it is soon closed then.

You also need these API definitions for user32.dll :

user32.decls
FindWindow_NameNull%(lpClassName$,lpWindowName%):"FindWindowA"
PostMessage%(hWnd%,Msg%,wParam%,lParam%):"PostMessageA"



Beaker(Posted 2005) [#4]
I presume that it won't bring the new window into your B+ app tho? And possibly won't work with other browsers.


Seldon(Posted 2005) [#5]
You're right. Actually I didn't think of that. But if you use flag 3 , you should be able to retrieve the link with HtmlViewEventURL$() and then you can simply pass the string to HtmlViewGO(). But I don't know if it works with external links (that is links that are opened on a new window.. in such case, it should be possible to retrieve the string passed to IE, with some work).

It only works with IE, but you can add few lines to look for other browsers: you've only to find the class window name.