javascript 调用 jsp的变量
找下面写法。
注意,加单引号,第2个百分号之前没有空格,而在jsp中调用的话要空格。
You may be get some help from the code below.
<%
String str="str";
%>
<script>
function accessVar(){
var varStr='<%=str%>';
alert(varStr);// here will diplay 'str'
}
</script>
相关文档:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor
*/
var File = {
name:'',
path:'',
ext:'',
cfiles:[],
attributes:{
  ......
1 JavaScript数组简介
JavaScript数组是一种包含已编码的值的复合数据。数组区别于关联数组,关联数组是将值和字符串关联在一起,而数组是将值和非负整数关联在一起。
数组是对象(可利用typeof运算符)。
2   ......
javascript操作Cookies方法集锦
function setCookie(name,value)
{
var Days = 1; //此 cookie 将被保存 1 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + ......
//关闭,父窗口弹出对话框,子窗口直接关闭
this.Response.Write("<script language=javascript>window.close();");
//关闭,父窗口和子窗口都不弹出对话框,直接关闭
this.Response.Write("");
this.Response.Write("{top.opener =null;top.close();}");
this.Response.Write("");
//弹出窗口刷新当前页面width=20 ......
大家可能都遇到过在写javascirpt代码时传递中文,在后台取到时发现是乱码,这里把我今天做的方法写出来,希望对大家以后有用!
方法(一):
html页面:
function testOne() {
var url = "testOne_test.do?expr="+你好;
location = encodeURI(url);
}
后台java代码:
String expr = ne ......