时间:2011-01-06 19:09:34

标签: javascript persistence frameset

1 个答案:

答案 0 :(得分:0)

*** 工作解决方案 ** *

<html>
<head>
<script type="text/javascript">
<!--
function loadFrameWidth(cookieName)
{
    if (document.cookie.length>0)
 {
     c_start = document.cookie.indexOf(cookieName + "=");
  if (c_start != -1)
  {
   c_start = c_start + cookieName.length + 1;
   c_end = document.cookie.indexOf(";",c_start);
   if (c_end == -1) { c_end=document.cookie.length; }
   document.getElementById('masterFrameset').cols = unescape(document.cookie.substring(c_start,c_end));
  }
  else { setStandardWidth(); }
 }
 else { setStandardWidth(); }
}

function setStandardWidth()
{
 document.getElementById('masterFrameset').cols = '150,*';
}

function storeFrameWidth(cookieName)
{
 var currentCols = document.getElementById('masterFrameset').cols;
 var exdate = new Date();
 exdate.setDate(exdate.getDate() + 7);
 document.cookie = cookieName + "=" + escape(currentCols) + 
 ";expires=" + exdate.toUTCString();
}
-->
</script>
</head>
<frameset id="masterFrameset" border="1" frameborder="1"
onLoad="loadFrameWidth('frameSetWidth')" onUnload="storeFrameWidth('frameSetWidth')">
  <frame id="controls" name="controlsFrame" src="toc.html" />
  <frame id="content" name="contentFrame" src="content.html" />
 </frameset>
</html>