Connecting Tech Pros Worldwide Help | Site Map

Event fired by "alert"

  #1  
Old July 24th, 2005, 11:55 PM
Alistair Saldanha
Guest
 
Posts: n/a
I'm looking for the event that is fired by Internet Explorer to an "alert":

<SCRIPT>
Alert("You already have a session open")
</SCRIPT>

The event would be webBrowser.Document.????

Much appreciate any help you can give me.
Thanks,
Alistair Saldanha



  #2  
Old July 25th, 2005, 03:35 AM
Danny
Guest
 
Posts: n/a

re: Event fired by "alert"




Ahhhhhh, what!?



Danny
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
  #3  
Old July 25th, 2005, 04:55 AM
Lee
Guest
 
Posts: n/a

re: Event fired by "alert"


Danny said:[color=blue]
>
>
>
> Ahhhhhh, what!?[/color]

That's a rather useless post, wasting the time of everyone who
reads it. You could have asked clarifying questions, or pointed
out specific misconceptions. In any case, I would hope that you
would also quote enough of the post that you were responding to
to allow others to know what you're questioning.

  #4  
Old July 25th, 2005, 05:45 AM
Alistair Saldanha
Guest
 
Posts: n/a

re: Event fired by "alert"


I am the person who made the original post. I didn't want to make my message
too long but it may have been too brief. I'm using Visual Basic to control a
WebBrowser control on a Visual Basic form through automation. For instance,
if someone clicks a button named Xbutton in Internet Explorer the Visual
Basic code would be:

WebBrowser.Document.All("Xbutton").OnClick = Class1

This will run the default method in Class1 when the user clicks Xbutton.

I'm looking for the same pathway for an alert:

<SCRIPT>
Alert("You already have a session open")
</SCRIPT>

I'm assuming the pathway would be something along the lines of:

WebBrowser.Document.All("???") = Class2

Thanks,
Alistair


"Alistair Saldanha" <dizzysal@cox.net> wrote in message
news:KXUEe.27410$mC.13022@okepread07...[color=blue]
> I'm looking for the event that is fired by Internet Explorer to an
> "alert":
>
> <SCRIPT>
> Alert("You already have a session open")
> </SCRIPT>
>
> The event would be webBrowser.Document.????
>
> Much appreciate any help you can give me.
> Thanks,
> Alistair Saldanha
>
>
>[/color]


  #5  
Old July 25th, 2005, 10:45 AM
VK
Guest
 
Posts: n/a

re: Event fired by "alert"




Alistair Saldanha wrote:[color=blue]
> I am the person who made the original post. I didn't want to make my message
> too long but it may have been too brief. I'm using Visual Basic to control a
> WebBrowser control on a Visual Basic form through automation. For instance,
> if someone clicks a button named Xbutton in Internet Explorer the Visual
> Basic code would be:
>
> WebBrowser.Document.All("Xbutton").OnClick = Class1
>
> This will run the default method in Class1 when the user clicks Xbutton.
>
> I'm looking for the same pathway for an alert:
>
> <SCRIPT>
> Alert("You already have a session open")
> </SCRIPT>
>
> I'm assuming the pathway would be something along the lines of:
>
> WebBrowser.Document.All("???") = Class2
>
> Thanks,
> Alistair[/color]

window.alert() is a method of the window object. It is not an event and
it doesn't fire any particular event. As on alert display focus goes to
the alert window, the parent window generates unload event. But it is
useless because unload may be caused by too many reasons.

Also window.alert is what we would call "final class" in other
languages. Thus it doesn't allow to change it's constructor to add
extra property/methods.

Alert doesn't appear automatically, but always has to be explicetly
called in the code. So what does prevent you from:

function foo() {
alert(message);
otherFunction();
}

?

  #6  
Old July 25th, 2005, 10:55 AM
Christopher J. Hahn
Guest
 
Posts: n/a

re: Event fired by "alert"


VK wrote:[color=blue]
> window.alert() is a method of the window object. It is not an event and
> it doesn't fire any particular event. As on alert display focus goes to
> the alert window, the parent window generates unload event. But it is
> useless because unload may be caused by too many reasons.
>
> Also window.alert is what we would call "final class" in other
> languages. Thus it doesn't allow to change it's constructor to add
> extra property/methods.
>
> Alert doesn't appear automatically, but always has to be explicetly
> called in the code. So what does prevent you from:
>
> function foo() {
> alert(message);
> otherFunction();
> }
>
> ?[/color]

How is alert a class? Final or otherwise? It's no more a class than,
say, setsockopt, or document.write, or print or echo.

Also, I think you may have gotten blur and unload confused. unload is
fired only when the current document is unloaded, i.e. when navigating
away from the document, or when closing the browser window. alert
causes the window (and children) to lose focus, causing a blur event,
not an unload.

Hope that clarifies it a bit.

  #7  
Old July 25th, 2005, 01:25 PM
Csaba Gabor
Guest
 
Posts: n/a

re: Event fired by "alert"


Alistair Saldanha wrote:[color=blue]
> I am the person who made the original post. I didn't want to make my message
> too long but it may have been too brief. I'm using Visual Basic to control a
> WebBrowser control on a Visual Basic form through automation. For instance,[/color]

As I understand it, within your VB code you want to be able to react to
an alert message being popped up, presumably by sending a keystroke to
it to dismiss it (or maybe even choose between options or enter input).
I suspect it would be too difficult to guess that the alert is coming
up and then spew a key to dismiss it.

This question is quite interesting, however, and I think it is better
addressed in the newsgroup: microsoft.public.vb.winapi
In particular, I think the call you are looking for is the windows API
SetWindowsHookEx with either WH_CBT (more probably) or WH_SHELL,
probably requiring a DLL. The class of the alert/confirm/prompt
(common dialog) windows are all "#32770" and alert has a single OK
button is a subwindow (class "Button"), while the other two each have
an OK and Cancel button, but the prompt window also has an Edit class
subwindow.

You might do a google search on: "32770" SetWindowsHookEx
Here's a useful page with some ideas:
http://groups-beta.google.com/group/...9d4612fdaec9f/

I'll look forward to seeing more on this topic,
Csaba Gabor from Vienna

  #8  
Old July 25th, 2005, 01:45 PM
Christopher J. Hahn
Guest
 
Posts: n/a

re: Event fired by "alert"


Csaba Gabor wrote:[color=blue]
> Alistair Saldanha wrote:[color=green]
> > I am the person who made the original post. I didn't want to make my message
> > too long but it may have been too brief. I'm using Visual Basic to control a
> > WebBrowser control on a Visual Basic form through automation. For instance,[/color]
>
> As I understand it, within your VB code you want to be able to react to
> an alert message being popped up, presumably by sending a keystroke to
> it to dismiss it (or maybe even choose between options or enter input).
> I suspect it would be too difficult to guess that the alert is coming
> up and then spew a key to dismiss it.[/color]

Just a thought-- I don't know whether or not this is even possible from
a VB app, but it would seem easiest to replace the window.alert method
with a no-op.

window.alert = function () { };

Don't know if you can do that, but if you can, do.

  #9  
Old July 25th, 2005, 02:05 PM
Csaba Gabor
Guest
 
Posts: n/a

re: Event fired by "alert"


Christopher J. Hahn wrote:[color=blue]
> Just a thought-- I don't know whether or not this is even possible from
> a VB app, but it would seem easiest to replace the window.alert method
> with a no-op.
>
> window.alert = function () { };
>
> Don't know if you can do that, but if you can, do.[/color]

Wow, Great idea!
<body onload="revamp()">
<script type='text/javascript'>
function revamp() {
// revamp the default alert function
var oldAlert = window.alert;
window.alert = function(alertMsg) {
window.status = alertMsg;
}

// proof of concept
alert("Hi mom");
oldAlert ("Hi dad");
// alert(""); // reset the status bar
}
</script>
</body>

And yes, you can do this from VB with:
IE.document.parentWindow.execScript _
"window.alert=function(alertMsg) {window.status=alertMsg;}"

Side note. If you're going to be creating variables off IE's
document that you can access from VB, I recommend doing
something to create it first like:
IE.document.parentWindow.execScript "window.myVar=0"
which will allocate the variable for use

Csaba Gabor from Vienna
PS. I didn't test this on the VB side, but I do it in other situations

  #10  
Old July 25th, 2005, 02:45 PM
Alistair Saldanha
Guest
 
Posts: n/a

re: Event fired by "alert"


Csaba,

Thank you so much for your post.

I cannot change the code in the WebBrowser, I am helping the end user react
to the WebBrowser using Visual Basic automation. The Visual Basic Automation
automatically enters the account number and other details so the end user
doesn't have to enter them manually. What's killing the VB automation are
the consant messages that pop up saying "Another session is running", which
is actually a bug in the WebBrowser coding, but it stops the VB automation
cold. So I'm hoping to do something to sidestep the alerts.

Alistair


"Csaba Gabor" <Csaba@z6.com> wrote in message
news:1122294020.083290.155270@z14g2000cwz.googlegr oups.com...[color=blue]
> Alistair Saldanha wrote:[color=green]
>> I am the person who made the original post. I didn't want to make my
>> message
>> too long but it may have been too brief. I'm using Visual Basic to
>> control a
>> WebBrowser control on a Visual Basic form through automation. For
>> instance,[/color]
>
> As I understand it, within your VB code you want to be able to react to
> an alert message being popped up, presumably by sending a keystroke to
> it to dismiss it (or maybe even choose between options or enter input).
> I suspect it would be too difficult to guess that the alert is coming
> up and then spew a key to dismiss it.
>
> This question is quite interesting, however, and I think it is better
> addressed in the newsgroup: microsoft.public.vb.winapi
> In particular, I think the call you are looking for is the windows API
> SetWindowsHookEx with either WH_CBT (more probably) or WH_SHELL,
> probably requiring a DLL. The class of the alert/confirm/prompt
> (common dialog) windows are all "#32770" and alert has a single OK
> button is a subwindow (class "Button"), while the other two each have
> an OK and Cancel button, but the prompt window also has an Edit class
> subwindow.
>
> You might do a google search on: "32770" SetWindowsHookEx
> Here's a useful page with some ideas:
> http://groups-beta.google.com/group/...9d4612fdaec9f/
>
> I'll look forward to seeing more on this topic,
> Csaba Gabor from Vienna
>[/color]


  #11  
Old July 26th, 2005, 07:15 AM
Christopher J. Hahn
Guest
 
Posts: n/a

re: Event fired by "alert"


Alistair Saldanha wrote:[color=blue]
> Csaba,
>
> Thank you so much for your post.
>
> I cannot change the code in the WebBrowser, I am helping the end user react
> to the WebBrowser using Visual Basic automation. The Visual Basic Automation
> automatically enters the account number and other details so the end user
> doesn't have to enter them manually. What's killing the VB automation are
> the consant messages that pop up saying "Another session is running", which
> is actually a bug in the WebBrowser coding, but it stops the VB automation
> cold. So I'm hoping to do something to sidestep the alerts.
>
> Alistair[/color]
[color=blue]
>From your description, it sounds like you're not dealing with[/color]
JavaScript alerts but WebBrowser MsgBoxes. We either need to see the JS
code of the page (everything in <script> tags) to determine for sure,
or if you already know that it's not a JS-alert(), then you're really
asking in the wrong newsgroup.

If it's not JS-related, a VB newsgroup or VB-WebBrowser newsgroup would
serve you best.

  #12  
Old July 27th, 2005, 12:15 AM
Alistair Saldanha
Guest
 
Posts: n/a

re: Event fired by "alert"


Thanks, Chris. I think I found the solution here:

http://www.thescarms.com/vbasic/subclassform.asp

Thanks for your help.

Alistair

"Christopher J. Hahn" <cjhahn@gmail.com> wrote in message
news:1122358150.966279.121780@g44g2000cwa.googlegr oups.com...[color=blue]
> Alistair Saldanha wrote:[color=green]
>> Csaba,
>>
>> Thank you so much for your post.
>>
>> I cannot change the code in the WebBrowser, I am helping the end user
>> react
>> to the WebBrowser using Visual Basic automation. The Visual Basic
>> Automation
>> automatically enters the account number and other details so the end user
>> doesn't have to enter them manually. What's killing the VB automation are
>> the consant messages that pop up saying "Another session is running",
>> which
>> is actually a bug in the WebBrowser coding, but it stops the VB
>> automation
>> cold. So I'm hoping to do something to sidestep the alerts.
>>
>> Alistair[/color]
>[color=green]
>>From your description, it sounds like you're not dealing with[/color]
> JavaScript alerts but WebBrowser MsgBoxes. We either need to see the JS
> code of the page (everything in <script> tags) to determine for sure,
> or if you already know that it's not a JS-alert(), then you're really
> asking in the wrong newsgroup.
>
> If it's not JS-related, a VB newsgroup or VB-WebBrowser newsgroup would
> serve you best.
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
rightclick "openlink" bypasses important javascript jerunyon@smartvoicecast.com answers 1 June 29th, 2007 01:25 PM