This website : http://blog.joins.com/media/folderListSlide.asp?uid=ddatk&folder=3&list_id=9960150
has this code:
<script>alert('¿Ã¹Ù¸¥ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.');</script>
So my web browser control show a popup, how can I bypass the popup without using sendkeys enter??
If you intend not to ever use the alert()
function on your page, you can also just override it. E.g.:
<script type="text/javascript">
alert = function(){}
</script>
If you do need to use JavaScript's alert function, you can 'overload' it:
<script type="text/javascript">
var fnAlert = alert;
alert = function(message,doshow) {
if (doshow === true) {
fnAlert(message);
}
}
alert("You won't see this");
alert("You will see this",true);
</script>
In the ProgressChanged
event handler, you insert a script element that replaces the Javascript alert
function with a function of your own, that does nothing:
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
string alertBlocker = "window.alert = function () { }";
element.text = alertBlocker;
head.AppendChild(scriptEl);
}
}
For this to work, you need to add a reference to Microsoft.mshtml
and use mshtml;
in your form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With