maria_papa
09-29-2003, 05:13 AM
Can anyone please help me??
How can you call a vbscript Sub from a javascript?
How can you call a vbscript Sub from a javascript?
|
Click to See Complete Forum and Search --> : calling a vbScript Sub from a javaScript function maria_papa 09-29-2003, 05:13 AM Can anyone please help me?? How can you call a vbscript Sub from a javascript? Khalid Ali 09-29-2003, 09:28 AM should be pretty simple.just use the sub name in the JavaScript maria_papa 09-30-2003, 06:16 AM nop......I did that. It doesn't work lillu 09-30-2003, 03:58 PM Well it's all about how vbscript (in ASP server-side I assume) and javascript (client-side) work together... If you have IE this will work: <script language="VBScript"> function VBsub(ByVal myMsg) MsgBox(myMsg) end function </script> Call the vbscript sub from somewhere in the page <img onClick="VBsub('Hello!');" /> Without IE, I think you have to send the sub call to the server for processing then it will send back the result to your browser. James L. 09-30-2003, 05:23 PM I am not familiar with the term VB "sub", as I don't know Visual Basic, but I have embedded Visual Basic code (is that a sub?) directly into a javascript routine when I did a school assignment that involved browser and plug in detection. Because IE Windows doesn't support the Navigator.plugins array, we could not use that method to detect if the Flash 6 plugin was present. The basic idea was to use Javascript to detect the browser, and if it was windows IE, then use the document.write method to write the visual basic script out. If it was any other browser that did support the navigator.plugins array then we just used Javascript for the detection. Something like this (CODE SNIPPET): if ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.appVersion.indexOf("Win") != -1)) // if the browser is a Windows based IE, use VBScript to determine which Flash version it is { document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); document.write('on error resume next \n'); document.write('correctFlashVersion = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n'); document.write('</SCR' + 'IPT\> \n'); } else.... the variable correctFlashVersion is a boolean previously defined within the Javascript. It worked fine having it defined by the embedded Visual Basic. Not too sure if this is what you are looking for or not. Hope it helps. Khalid Ali 09-30-2003, 10:53 PM Originally posted by maria_papa nop......I did that. It doesn't work In that case I can only say that you did not implemented the code correctly.. the code below will work in IE the first part is in JavaScript and the second is in VBScript.if you click the button it will call javascript function which calls VBScript function that will print "hello from VBScript " string. <script type="text/javascript"> <!-- function CallVBFunc(){ VBFunc(); //alert("Called"); } //--> </script> <script type="text/VBScript"> <!-- sub VBFunc() document.write "Hello From VBScript" end sub //--> </script> </head> <body> <input type="button" value="Call VB Function" onclick="CallVBFunc();"/> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |