Joke Collection Website - Mood Talk - How to get the value of java variables in js, friends help me talk about it.

How to get the value of java variables in js, friends help me talk about it.

Theoretically, the variable values of Java cannot be obtained in js, but they can be obtained indirectly. Two ideas are provided for reference: 1, the value of java variables is stored in cookies, and js takes the value through cookies; & ltpre t="code" l="js "> function getCookie (name)

{

Var arr, reg = new regexp ("(|)"+name+"= ([; ]*)(; |$)");

if(arr = document . cookie . match(reg))

Return UNESCAPE (arr [2]);

other

Returns null

}

var value = get cookie(" cookie name "); 2. Assign the value of java variable to the page.