Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello,
Alright guys, sorry for bad question, I'll try to explain it better. All I have is simple webBrowser and I want to try to use it to avoid popping message from random server. That "popping message" looks exactly like normal message box but since somebody told me there's nothing like message box from server then I have no idea how to call it :D. It pops out when you click on the button on the website. So I was thinking about if there's some kind code which can close/block it without user needing to interfere. Maybe some kind of block using the message's header would be enough :). But after searching for hours all I've found was INewWindowManager interface and I just couldn't get it to work. I don't have any special codes for this I just use webBrowser and websites where I'm trying to do this are not mine so I can't provide any code of mine.
Thanks for any help!
Posted
Updated 27-Feb-13 9:01am
v3
Comments
Sergey Alexandrovich Kryukov 27-Feb-13 13:57pm    
There is no such thing as "message boxes from server". Without appropriate code sample, who know if you screw up something and where?
—SA
AspDotNetDev 27-Feb-13 14:33pm    
In the past, I have created instances of WebBrowser controls (on the server) in order to render web pages, which I then embedded into PDFs (when then got served up to the client for download). If some JavaScript initiated an alert() during that process, that could potentially screw things up. I suspect this is what the OP is talking about, but OriginalGriff is right that they should clarify so we don't waste our time trying to read their mind.
OriginalGriff 27-Feb-13 13:58pm    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
loctrice 27-Feb-13 14:05pm    
I'm saving this for proof that you can't do the things mentioned. I will use it against you in the lounge some day for sure.
OriginalGriff 27-Feb-13 14:15pm    
-shhh- I'm trying to hide my super powers.

1 solution

As far as I understand you need to block message boxes like alert(), or confirm() to make sure that they'll not stuck your scripts. If yes, what can I suggest is to render (execute) following script in your hidden browser:

JavaScript
alert = function(){};
confirm = function(){}; 


Works perfectly for me in chrome, firefox, and doesn't work in IE.
 
Share this answer
 
v2
Comments
LosEagle 28-Feb-13 2:41am    
Yes you perfectly understand what I need to do :). But I need to make webBrowser from Visual Studio to do this and the problem is that VS uses IE :(. But thanks for help anyway! Will note this answer as it seems useful.
Volodymyr Bobko 28-Feb-13 5:40am    
Just checked once again and -
it doesn't work in IE8 and IE7, and works fine in IE9.

But in IE 8/7 you can achieve the same result with the following script:
var alert = function(){};
alert(); // do nothing
LosEagle 28-Feb-13 11:11am    
This looks like it can work but how can I please use this? I'm totally new in scripting so sorry for stupid questions.
Volodymyr Bobko 28-Feb-13 15:26pm    
If you can preprocess web page HTML before passing it to your browser you can insert this script directly into your web page.
<script language="javascript">
var alert = function () { };
var confirm = function () { return true; }
</script>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900