发信人: wuga(冰雨梦)
整理人: wuga(2001-11-24 11:31:51), 站内信件
|
Using Hidden FRAMES to Hold Data or Maintain State
开发网络应用程序不是一件简单的事,有时我们需要一种有效的方法去保持页面中的数据。如果你的客户段支持cookies,那你可以用Session变量。但这样并不通用。这时你可以用隐藏框架来保持页面中的各种数据,而不须担心客户端是否支持。
作一个隐藏的框架很简单。你只需要生成一个尺寸占浏览器百分之百的框架,同时以剩余尺寸生成一个框架,如果我没算错的话,是百分之零。例如:
<frameset rows="100%,*" framespacing="0">
<frameset cols="50%,50%" framespacing="0">
<frame name="productsFrame" src=" spacer.asp" scrolling="auto">
<frame name="cartFrame" src="spacer.asp" scrolling="auto">
</frameset>
<frame name="hiddenFrame" src="cartData.asp">
</frameset>
有一点要注意的是:每个框架都应该有页面内容,如上面的:spacer.asp、cartData.asp。否则有的浏览器如Netscape将用它的默认页来填充。则会产生不确定的问题。
var numberOfProducts = 4;
//create a new array
var ourProductArray = new Array(numberOfProducts + 1);
//this element holds the array size
ourProductArray[0] = numberOfProducts + 1;
// now, populate the array with products
ourProductArray[1] = new item(1,'Player Piano',1500)
ourProductArray[2] = new item(2,'Trombone',400)
ourProductArray[3] = new item(2,'Clarinet',350)
ourProductArray[4] = new item(2,'Ukulele',300)
然后,我们初始化另一个数组,它用来保存我们的车数据。
var ourCartArray = new Array(1);
ourCartArray[0] = 0; // set the size to 0 (number of cart items).
---- 北京社区体育运动中国足球版副
北京社区编程世界ASP版副
还要常来绿荫风云聊聊呀~~
:乱灌者严惩!
|
|