jQuery并保存页面之间的参数
能记住潜水舱的高度吗?例如,在一个网站上,我展开有一些内容的div,然后单击另一个具有不同内容但具有相同div(相同id和类)的页面。不幸的是,一切都恢复正常,并失去了div的高度 我在html中得到了框架的效果(但是你怎么看它不像我想的那样工作)。花了多长时间?是否将数据保留在会话中?需要例子jQuery并保存页面之间的参数,jquery,html,css,spring,Jquery,Html,Css,Spring,能记住潜水舱的高度吗?例如,在一个网站上,我展开有一些内容的div,然后单击另一个具有不同内容但具有相同div(相同id和类)的页面。不幸的是,一切都恢复正常,并失去了div的高度 我在html中得到了框架的效果(但是你怎么看它不像我想的那样工作)。花了多长时间?是否将数据保留在会话中?需要例子 我使用的是jQuery,SpringMVC,如果有人问,你可以简单地使用HTML5本地存储机制 您可以根据需要使用.height()、.innerHeight()或outerHeight() 下面是一
我使用的是jQuery,SpringMVC,如果有人问,你可以简单地使用HTML5本地存储机制 您可以根据需要使用
.height()
、.innerHeight()
或outerHeight()
下面是一个例子-
jquery
if(localStorage.divheight) //extract the old height
{
// handle the height as you want here
alert('Old height from local storage: '+ localStorage.divheight);
}
//Code just to show the mechanism of LocalStorage
$(document).ready(function(){
$('#result').click (function () {
//Remember the height
localStorage.divheight = $("div").height();
//Tell the user the freshly stored height
alert("New height: "+localStorage.divheight);
});
});
HTML
<div id="result">
Some number of lines here....
Lorem ipsum dolor sit amet, consectetur adipisicing elit
. Fuga earum id fugit veritatis! Pariatur, magni.
</div>
这里有几行。。。。
Lorem ipsum dolor sit amet,奉献精英
. 真是太棒了!木偶,木偶。
看一看。♦