• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1219
  • Last Modified:

suppress javascript Alerts from webBrowser c#

I am trying to change the values  using web interface of a modem(it is a rs485 to ethernet convertor not complately a modem. i dont have an access to update firmware.). 0 am Using webBrowser1 class .when I invoke the submit i take an alert (with one ok button)  from javascriptthat writes " please refresh the page" on it but it isn't neccesary to refresh it it is bullshit.I want to disable this alert programmaticaly.refreshing the page alert is not an error just a warning when i submit the form the values are already change, before i have said it is an alert and also very  trivial.How can I do this?
0
fsarp
Asked:
fsarp
  • 8
  • 6
1 Solution
 
nordtorpCommented:
I think the same is asked for in this thread.

See if you get any clues from that.

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_25015372.html
0
 
CSecurityCommented:
After navigation and submitting form or anything you do, when you know alert box has just appeared, do this:

SendKeys.Send("{ENTER}");

That's all
0
 
fsarpAuthor Commented:
CSecurity i tried that before but it doesnt work .
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CSecurityCommented:
Try to focus form, try to set focus on it. Then it will work. Also try to set focus on Webbrowser then send the key
0
 
fsarpAuthor Commented:
When i was debugging i cant see javascript responses so i cant focus
0
 
CSecurityCommented:
Without debugging, I mean if you run it normally, it will work.

Also if you can inject/modify HTML code, you can do that too.
0
 
fsarpAuthor Commented:
I cant modify firmware.
1.how can i focus on javascript alert?
2. you said also try  focus webBrowser could you give me an example on focusing
0
 
CSecurityCommented:
WebBrowserControl.SetFocus()
0
 
CSecurityCommented:
0
 
fsarpAuthor Commented:
after submitting form there is time delay after a while alert window opens when i make thread.sleep i cant catch
0
 
CSecurityCommented:
Do this:

Submit Form
Thread.Sleep
SetFocus
SendKeys

All of these should be in same function/context/thread
0
 
fsarpAuthor Commented:
focusing and sendkey doesnt work.

I need an other ways to supress alert
0
 
CSecurityCommented:
No more ideas. I solved EXACTLY same problem, just in Visual Basic 6 with SendKeys... Try to figure it out and do it...
0
 
fsarpAuthor Commented:
i created form evet which is deactivated
than send esc key
because when alert occurs form become deactivated..
0
 
CSecurityCommented:
I'm going to say #3, we helped enough, idea was sending ESC key, I solved same problem for myself using same method. Also modifying HTML code was suggested which wasn't case for asker. But generally experts helped enough and only thing asker should handle was how to activate form and send key, idea of activating and sending key was provided in question. So I would say #3.

Thanks
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now