[英]how can i pass the data from one view to another using client side only?
My scenario is that i am building a framework like web application where user can build his own page and he/she can preview it. 我的情况是,我正在构建一个像Web应用程序这样的框架,用户可以在其中构建自己的页面,并且他/她可以对其进行预览。 Giving the preview functionality on the same page is pretty easy but i want to give it on a new pop up window which will open on a button click.
在同一页面上提供预览功能非常容易,但我想在一个新的弹出窗口中提供它,单击该按钮即可打开。 Here i want to pass a JavaScript variable from one view to another(may be an HTML page),and i don't want to use server for this task because the data is pretty temporary so at the client side how can i pass the variable using JavaScript or j-Query ?
在这里,我想将JavaScript变量从一个视图传递到另一个视图(可能是HTML页面),并且我不想使用服务器来执行此任务,因为数据是非常临时的,因此在客户端如何传递变量使用JavaScript还是j-Query?
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>
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.