Passing variables in JS and vbs

Source: Internet
Author: User
Tags setcookie

I. Client to client

1. vbs to JS

 

<Script language = "VBScript" type = "text/VBScript">
Dim Jstovbs
Jstovbs = "jstovbs"

Document. writeln ( "I'm vbs :"& Jstovbs)
</SCRIPT>

<Br/>
<Script language = "JavaScript" type = "text/JavaScript">
Document. writeln ( "I am JS:" + jstovbs );// The jstovbs variable is defined and assigned values in vbs.
</SCRIPT>

 

2. js to vbs

 

<Script language = "JavaScript" type = "text/JavaScript">
VaR jstovbs = "jstovbs" ;
Document. writeln ("I Am a JS:" +
Jstovbs );
</SCRIPT>

<Br/>
<Script language = "VBScript" type = "text/VBScript">
Document. writeln ( "I'm vbs:" & jstovbs) // The jstovbs variable is defined and assigned a value in Js.
</SCRIPT>

 

II. Server to client

1. vbs to JS

<% @ Language = "VBScript" codePage = "936" %>

<%
Dim
Vbstojs
Vbstojs = "vbstojs"

%>

<Script language = "JavaScript" type = "text/JavaScript">
VaR JS= '<% = Vbstojs %> ';
Document. writeln ("I Am a JS:" +JS );
</SCRIPT>

 

2. js to vbs

 

<% @ Language = "JavaScript" codePage = "936" %>

<%
VaR jstovbs = "jstovbs"

%>

<Script language = "VBScript" type = "text/VBScript">
DimVbs
Vbs = "<% = jstovbs %>"

Document. writeln ("I'm vbs :"&Vbs)
</SCRIPT>

 

3. Client to server

1. vbs to JS

See 2

2. js to vbs

(1) Cookies (submitted and received on the same page, need to be refreshed)

<Script language = "JavaScript" type = "text/JavaScript">
Function Setcookie (name, value, expires, path, domain, secure)
{
VaR mycookie = Name + "=" +
Encodeuricomponent (value );

If
(Expires)
{
Mycookie + = "; expires =" +
Expires. togmtstring ();
}

If
(PATH)
{
Mycookie + = "; Path =" +
Path;
}

If(Domain)
{
Mycookie + = "; domain =" +
Domain;
}

If(Secure)
{
Mycookie + = "; secure"
;
}

Document. Cookie =
Mycookie;
}

Setcookie ('jstovbs ', 'jstovbs cookies', false);
</SCRIPT>

<%
Dim vbs
Vbs
= Request. Cookies ("jstovbs")
Response. Write (vbs)
%>

 

(2) automatic submission (get mode, two pages)

A. js.html (client)

 

<Script language = "JavaScript" type = "text/JavaScript">
// You can define a function that is automatically submitted as needed.
Location. href = "ASP. asp? Jstoasp = this variable is passed by the client JS" ;
</SCRIPT>

 

B. asp. asp (server side)

 

< %
Dim
Vbs
Vbs = request. querystring ("jstoasp"
)
Response. Write (vbs)
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.