If there are any mistakes, please point them out, thank you
1. Ordinary global variables
In the browser, there are many ways to reference a global variable. You can reference the variable directly or use window. variable to refer to global variables. The reason is that global variables belong to the window form, but every time a new window is opened, the browser will automatically clear the previous variables (that is, each new page is a "clear" "web page", so previously defined variables cannot be referenced in a newly opened window. If you want to reference them, you can obtain them in a different direction, such as by passing parameters in the URL, but this is a story later) For example:
Output result:
this is a global var.
this is a global var.
2. vbs References to js objects (non-prototype objects) and functions
can be directly referenced: object name. Attribute name
Output result:
change
hange
When js is prototype type, vbs can use the following method to access members of js
3. To call a class in vbs in js, you can first create an instance in vbs. js can access the members of vbs through this instance.
Output result:
blueDestiny
4. When js calls the array defined by vbs, you can directly use the subscript to get the first The value of several elements.
Output result:
blue
destiny
However, how to convert a vbs array into a js array Woolen cloth? You can use the VBArray() object of js and the toArray() method. It is worth noting that the toArray() method results in a one-dimensional array:
Output results:
1 2 3
4 5 6
7 8 9
1 2 3 4 5 6 7 8 9
5. Convert js array to vbs Array:
Get the array length of js, you can directly use the length attribute to get
<script> <BR>var global = "this is a global var." <BR></script> <script> <BR><!-- <BR>alert(window.global) <BR>alert(global) <BR>//--> <BR></script><script> <BR><!-- <BR>function obj(){}; <BR>obj.string="test"; <BR>obj.replacec=function(s){return s.replace(/c/,"")}; <BR>//--> <BR></script> <script> <BR><!-- <BR>alert(obj.string) <BR>obj.string="change" <BR>alert(obj.string) <BR>alert(obj.replacec(obj.string)) <BR>//--> <BR></script><script> <BR><!-- <BR>function myClass(s) <BR>{ <BR> this.s=s <BR> return this; <BR>}; <BR>myClass.prototype.output=function() <BR>{ <BR> alert(this.s); <BR>} <BR>var obj=new myClass("blueDestiny"); <BR>//--> <BR></script>Output result: <script> <BR><!-- <BR>obj.output() <BR>//--> <BR></script>2 <script> <BR><!-- <BR>class myClass <BR> public s <BR> public sub alertstring() <BR> alert(s) <BR> end sub <BR>end class <BR>set obj=new myClass <BR>//--> <BR></script><script> <BR><!-- <BR>obj.s="blueDestiny" <BR>obj.alertstring() <BR>//--> <BR></script>If you want to access the array elements of js through subscripts, you will not be able to get it, but you can use the existing methods: join() (method in js) and Split() <script> <BR>dim a(2) <BR>a(0)="blue" <BR>a(1)="destiny" <BR></script><script> <BR><!-- <BR>alert(a(0)) <BR>alert(a(1)) <BR>//--> <BR></script><script> <BR><!-- <BR>Function CreateVBArray() <BR> Dim i, j, k <BR> Dim a(2, 2) <BR> '初始化二维数组 <BR> k = 1 <BR> For i = 0 To 2 <BR> For j = 0 To 2 <BR> a(j, i) = k <BR> document.writeln(k) <BR> k = k + 1 <BR> Next <BR> document.writeln("<BR>") <BR> Next <BR> CreateVBArray = a <BR>End Function <BR>--> <BR></script> <script> <BR><!-- <BR>function VBArrayTest(vbarray) <BR>{ <BR> //调用VBArray()对象,将vbs数组转化为js的数组并调用toArray()方法得到一维数组。 <BR> var a = new VBArray(vbarray); <BR> var b = a.toArray(); <BR> var i; <BR> for (i = 0; i < 9; i++) <BR> { <BR> document.writeln(b[i]); <BR> } <br><br>} <BR>VBArrayTest(CreateVBArray()); <BR>--> <BR></script><script> <BR><!-- <BR>var arr=["blue","Destiny"]; <BR>//--> <BR></script>Output result<script> <BR><!-- <BR>alert(arr.length) <BR>//--> <BR></script>blue <script> <BR><!-- <BR>'注:这里不可用vbs的join(arr,",")方法,实际上这里所用到的是js里的join方法,并且为vbs的 <BR>vbarr=arr.join(",") <BR>vbarr=split(vbarr,",") <BR>alert(vbarr(0)) <BR>alert(vbarr(1)) <BR>//--> <BR></script>Destiny

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

Matter.js is a 2D rigid body physics engine written in JavaScript. This library can help you easily simulate 2D physics in your browser. It provides many features, such as the ability to create rigid bodies and assign physical properties such as mass, area, or density. You can also simulate different types of collisions and forces, such as gravity friction. Matter.js supports all mainstream browsers. Additionally, it is suitable for mobile devices as it detects touches and is responsive. All of these features make it worth your time to learn how to use the engine, as this makes it easy to create a physics-based 2D game or simulation. In this tutorial, I will cover the basics of this library, including its installation and usage, and provide a

This article demonstrates how to automatically refresh a div's content every 5 seconds using jQuery and AJAX. The example fetches and displays the latest blog posts from an RSS feed, along with the last refresh timestamp. A loading image is optiona


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft