0

我的场景是我正在构建一个像 Web 应用程序这样的框架,用户可以在其中构建自己的页面并且他/她可以预览它。在同一页面上提供预览功能非常简单,但我想在一个新的弹出窗口上提供它,该窗口将在单击按钮时打开。在这里,我想将一个 JavaScript 变量从一个视图传递到另一个视图(可能是一个 HTML 页面),我不想使用服务器来完成这项任务,因为数据是非常临时的,所以在客户端我如何传递变量使用 JavaScript 或 j-Query 吗?

4

2 回答 2

0
if pass the one page to another page means simple to use cookies.otherwise using only on inside single page  use the following code.
var a;
var b;
var x=10;
var y=mark;
<button onclick="myfunction(\''+x+'\',\''+y+'\');">click</button>
function myfunction(x,y)
{
a=x;
b=y;
console.log(a,b);
}
于 2013-06-24T11:41:14.157 回答
0
in using a jquery plugin have a js for cookie.the following example can useful for u.
first set value into cookie the following way
 <script src="js/jquery.cookie.js"></script>
   $.cookie("Token",value);
in another page u get this cookie using cookie name. 
   var Cookie=$.cookie("Token");
when  u need to pass a value use this source on that page with jquery plugin.
<script src="js/jquery.cookie.js"></script>
于 2013-06-24T07:58:38.673 回答