0
votes

Ok, my program encounters some javascript which I want to block/redirect:

<SCRIPT language="Javascript">



<!--

var sWidth = screen.availWidth-10;



var sHeight = screen.availHeight-50;



var demo=window.open('/url/path/to/open', '', 'scrollbars,status,width=' + sWidth +    ',height=' + sHeight);


window.opener = top;

//opener.close();

window.open("javascript:'<script>window.close()</script>'", "_self"); 



//-->



</SCRIPT>

when this happens i want to block those actions and just redirect my webbrowser control to '/url/path/to/open' so it opens in the same window. I assume its something to do with webbrowser.document and that i need to dump the document, check it for the JS and then once found handle it back into the control but I am not totally sure. Anyone have any ideas?

1

1 Answers

0
votes

the following code helps to handle this on the new window event:

    If sender.documenttext.contains("window.open") Then
        e.Cancel = True
        WebBrowser1.Navigate("/url/path/to/open") 'plug in the new window url as string 
    End If