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.'