stopping popup windows in a web browser

王朝c#·作者佚名  2006-12-17
宽屏版  字体:  |  |  | 超大  

Leader)

posts: 1481

since: Apr 8, 2001

from: Shropshire, England

http://www.vbcity.com/forums/topic.asp?tid=22075&highlight=beforenavigate&page=2

Hi,

As most 'unwanted' pop-ups occur during the 'OnLoad' event of the Body element, you can expand on cancelling the NewWindow by determining whether the document being loaded has completed:

Code:

Cancel =

Debug.Print

Cancel =

Debug.Print

Debug.Print

WebBrowser1.Silent =

I'm not sure how you can get the NewWindow's target URL without allowing the new window to open.

The code will redirect any Target="_blank" type navigation to the original window, but will allow user-activated links that are script based to open in a new window - this would probably be the point at which to implement a new form and RegisterAsBrowser code. An example is the 'Comment' link in a Microsoft KB article which uses javascript to open the target window.

Code:

sLink = WebBrowser1.Document.parentWindow.event.srcElement.href

Debug.Print & sLink

Cancel =

WebBrowser1.Navigate sLink

Debug.Print

Cancel =

sLink = WebBrowser1.Document.activeElement.href

Cancel =

Debug.Print & sLink

Cancel =

WebBrowser1.Navigate sLink

Debug.Print

Cancel =

Cancel =

Hope that helps

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有