Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2004, 11:15 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default linking to external vbscript file

I have an external vbscript file that I have linked to my page in the head. I am writing some javascript to intereact with the functions in the external .vbs file. Here is the external script code...

Dim o3web

Sub window_onload
   Set o3Web = createObject("triadweb.cls3Web")
   o3Web.Init()
End Sub

Sub window_unload
   Set o3Web = NOTHING
End Sub

Function sCurrentUser()
   sCurrentUser=o3Web.sCurrentUser()
End Function

Here is my javascript/head code...

<script language="VBScript" src="score.vbs" type="text/VBScript"></script>

<script language="JavaScript">
    var sUser=o3Web.sCurrentUser();
</script>

I am getting the error that o3Web is null. Does anyone know why?

Clay Hess
__________________
Clay Hess
 
Old April 19th, 2004, 03:29 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

This is because the VBScript can not directly interact with the Javascript in this way. you could try using the QueryString or a form field, which both Javascript and VBScript can access.
 
Old April 20th, 2004, 03:38 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Clay,

The problem is that you javascript is being executed as soon as it is reached & you vbscript when the Window_Onload event fires.

One way to get round this would be to call a javascript function at the end of your Window_Onload(), something like...

<script language="vbscript">
Dim dom
Sub Window_Onload()
    Set dom = CreateObject("Msxml2.DomDocument.4.0")
    dom.async = False
    dom.loadXML("<parenttag><childtag /></parenttag>")
    DoJs()
End Sub
</script>

<script type="text/javascript">
function DoJs(){
    alert(dom.xml);
}
</script>

HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
No such file or directory error for wrong linking awotta BOOK: Professional Assembly Language 1 January 10th, 2010 07:44 AM
Calling to an external .jar file tony_s XSLT 3 December 16th, 2006 05:20 PM
Call or linking to external .jar file tony_s Java Basics 0 December 16th, 2006 05:20 PM
linking in vbscript MuthuAL Classic ASP Databases 5 December 10th, 2004 03:08 AM
Opening file external kaivanrijswijk VBScript 0 March 29th, 2004 05:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.