Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mixing vbscript and Javascript on a single page

Status
Not open for further replies.

goldsmmi

Programmer
Apr 18, 2001
2
US
I am trying to compose an html page that contains both vbscript and javascript functions. They are called from completely different parts of the page - and all the scripts are tagged with the correct language (ie <script langauge=&quot;vbscript&quot;> etc)..... the only problem is that the browser (ie5) will execute the javascript and flag errors on the vbscript (the code has been tested in a seperate page and works fine) Its seems to me that once the browser starts to parse a particular script language it isn't switching to a different parser. Is it possible to get ie5 to do this?? - I am aware that I could recode one of the two scripts into the other language.... but they are very long pieces of code and this would take a long time. It would be far far easier if it was possible to get the browser to interpret two script langauges in one page. Any suggestions??
 
Though it's recommended not to do this (because of resources), it can be done. I don't know why it doesn't work in your case - perhaps you have functions named the same in both scripts? Also, make sure you spell &quot;LANGUAGE&quot; correctly, your script blocks are in your <head> and you have included your ending script tags! Anyway, this is all you do:

Code:
<!--***********************************-->
<!--	VBSCRIPT Client-side code      -->
<!--***********************************-->
<script LANGUAGE=&quot;VBSCRIPT&quot;>
vbscript code here
</script>

<!--***********************************-->
<!--	JAVASCRIPT Client-side code    -->
<!--***********************************-->
<script LANGUAGE=&quot;JavaScript&quot;>
jscript code here
</script>
 
I combine them with no problem. You probably just have a minor syntax problem or orphaned tag somewhere. This is sometimes difficult to track down in a complex page, so my recommendation is to simplify. Break your page up into small testable units. Comment out unnecessary details until you can track down your problem. If you post some code, perhaps we can analyze it further.

good luck
 
I am facing the same problem -- of getting an error when mixing VBScript and JavaScript in the same page. Did you figure out what your problem was?
 
Hey guys - I found something pretty interesting, which might explain the error(s) encountered:

&quot;Explorer recognizes both languages, but considers JavaScript to be the default scripting language. The default language, however, is automatically changed to reflect the first language used on a page.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top