473,566 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a Javascript function from a message box

Hello all,

I have simple function that I call from an alert box

alert(testScore );

It works fine. Unfortunately, I do not like the sound and Exclamation
point icon that appears. I'd like a nice message box like VBA message
box #64 to appear. I know hardly anything at all about VB or VBA.
But, I do know you can call a VB function from Javascript. How? Is it
possible to get my testScores to appear from the VB function? Is it
hard? Where do I start looking?

Thanks
Kim
Jul 20 '05 #1
3 21462
ki********@tch. harvard.edu (Kim Forbes) writes:
I have simple function that I call from an alert box alert(testScore ); It works fine. Unfortunately, I do not like the sound and Exclamation
point icon that appears.
There is no sound or exclamation point in my browser.
I'd like a nice message box like VBA message
box #64 to appear. I know hardly anything at all about VB or VBA.
Me neither, so I don't know what a message box #64 is.
But, I do know you can call a VB function from Javascript.
Not in my browser. I.e., not in general. The specific case where it
works is Internet Explorer on Windows. You are not running Javascript,
but JScript, which has access to the Windows Scripting Host, just like
VBA.
How? Is it possible to get my testScores to appear from the VB
function? Is it hard? Where do I start looking?


Since it is Microsoft IE only, a good guess would be Microsoft's
webpage, searching for JScript and WSH.

This script will use the WSH function, but will require the user to
allow the ActiveXObject creation (at least in my security setting) .
---
<script type="text/javascript">
function myAlert(str) {
if (window && window.WScript) {
var shell=new ActiveXObject(' WScript.Shell') ;
shell.Popup(str ,undefined,unde fined,64); // that's the #64?
} else {
alert(str);
}
}
---

You could also make a VBScript function and call it from JScript:
---
<script type="text/vbscript">
Function VBMsgBox(txt)
MyMsgBox = MsgBox(txt,64)
End Function
</script>
<script type="text/javascript">
function myAlert (str) {
if (typeof VBMsgBox != "undefined" ) {VBMsgBox(str); }
else {alert(str);}
}
</script>
---

In both cases, you must fall back on "alert" for all other browsers and
platforms.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
you can call a vbscript function from javascript but in my
experience you will have to write the vbscript function first.

<script language="vbscr ipt">
function alert(x)
messagebox(x)
End
</script>

<script language="javas cript">
messagebox("bla h")
</script>

be aware though that not all browsers will support vbscript
I may be wrong but I think it will only be ie4 +

Hope this helps

Simon Christie

"Kim Forbes" <ki********@tch .harvard.edu> wrote in message
news:de******** *************** ***@posting.goo gle.com...
Hello all,

I have simple function that I call from an alert box

alert(testScore );

It works fine. Unfortunately, I do not like the sound and Exclamation
point icon that appears. I'd like a nice message box like VBA message
box #64 to appear. I know hardly anything at all about VB or VBA.
But, I do know you can call a VB function from Javascript. How? Is it
possible to get my testScores to appear from the VB function? Is it
hard? Where do I start looking?

Thanks
Kim

Jul 20 '05 #3
Kim Forbes wrote:
I have simple function that I call from an alert box

alert(testScore );

It works fine.
Forgive me but I do not see any function here [except of alert(...)].
Unfortunately, I do not like the sound and Exclamation
point icon that appears. I'd like a nice message box like VBA message
box #64 to appear.
How does that box look like?
I know hardly anything at all about VB or VBA.
Not a very promising start.
But, I do know you can call a VB function from Javascript.
In Internet Explorer, it is possible to call
a VBScript subroutine from JavaScript.
How?
<script type="text/vbscript" language="VBScr ipt">
<!--
Sub foobar
MsgBox "Hello, world!"
End Sub
'-->
</script>

<script type="text/javascript" language="JavaS cript">
<!--
foobar();
//-->
</script>
Is it possible to get my testScores to appear from the VB function?
<computer> Please restate your request. </computer>
Is it hard? Where do I start looking?


A manual of your choice, possibly <http://msdn.microsoft. com/library/>,
or a group of the microsoft.* hierarchy. VB(Script)/VBA is off-topic here.
PointedEars

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7497
by: R.G. Vervoort | last post by:
I am using a javafunction (onclick in select) in which i am calling a function in php (thats why i send this to both php and javascript newsgroups). in the onclick i call the function "Place_Selected" with the value from the select (naam_keuze.value) in the function the value becomes the $zoek_id and searches in the database for the...
14
9562
by: Michael Winter | last post by:
In an attempt to answer another question in this group, I've had to resort to calling the DOM method, Node.removeChild(), using a reference to it (long story...). That is, passing Node.removeChild. In Opera (7.23/Win), the call appears to do nothing - the node remains - but no errors are shown. In Netscape (7.0/Win), an exception results....
18
12647
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes state, the HTML page URL would change from default.html to default.html#stateA. example: http://pearstudios.com/javascript/locationHashAndFlash.html ...
5
51476
by: Krishna | last post by:
Hi all, Can i call my javascript functions from the web controls.Any appropriate site which will be tell more on this will be helpfull. Regards.., Krishna
6
751
by: szabelin | last post by:
Hello, I am trying to call a function inside the javascript block from asp.net during the postback (NOT button's OnClick event handler though). The javascript function creates new popup window. I register the javascript code with the RegisterClientScriptBlock. How how do I call the javascript function inside the block from within C#...
4
6545
by: Anita C | last post by:
Hi, Can one call a c# function from within a javascript function ? I have a c# function GetLanguageItem(title), how can I call the above function from a javascript function in an .aspx page. Thanks
7
1559
by: Roger | last post by:
Is this possible?? client side: <script language="jscript"> function hello() { window.alert("HELLO!"); } </script>
4
6306
by: Martin Feuersteiner | last post by:
Dear Group I'm using VB to write an aspnet application. I would like to call a javascript function from within a VB Sub or VB Function, is it possible? My code is something like this: VB Code: Public Sub VBProcedure() .. ..
1
2403
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the instructions on where to normally place them in an XHTML document: SCRIPT #1: Step 1: Insert the below anywhere into the <body> section of your page...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.