473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 21446
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,undefined,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/rasterTriangleDOM.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="vbscript">
function alert(x)
messagebox(x)
End
</script>

<script language="javascript">
messagebox("blah")
</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.google.c om...
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="VBScript">
<!--
Sub foobar
MsgBox "Hello, world!"
End Sub
'-->
</script>

<script type="text/javascript" language="JavaScript">
<!--
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
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...
14
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....
18
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...
5
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
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...
4
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....
7
by: Roger | last post by:
Is this possible?? client side: <script language="jscript"> function hello() { window.alert("HELLO!"); } </script>
4
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.