用Ajax来控制书签和回退按钮的代码

2019-09-14 07:29:47于海丽

               i < window.addressBook.length;
                     i++) {
         sectionData += "<li>"
                        + window.addressBook[i]
                        + "</li>";                  
      }

      sectionData += "</ul>";
   }

   // If there is no sectionData, then
   // remotely retrieve it; in this example
   // we use fake data for everything but the
   // address book
   if (sectionData == null) {
      // in a real application we would remotely
      // fetch this section's content
      sectionData = "<p>This is section: "
         + selectedElement.innerHTML + "</p>";  
   }

   // update the content's title and main text
   var contentTitle =
         document.getElementById("content-title");
   var contentValue =
         document.getElementById("content-value");
   contentTitle.innerHTML =
                        selectedElement.innerHTML;
   contentValue.innerHTML = sectionData;
}


  演示(Demo)O'Reilly Mail或者下载(download)O'Reilly Mail的源代码。

  结束语

  你现在已经学习了使用Really Simple History API 让你的AJAX应用响应书签和前进回退按钮,而且有代码可以作为创建你自己的应用的素材。我热切地期待你利用书签和历史的支持完成你的AJAX创造。

版权声明:Techtarget获Matrix授权发布,如需转载请联系Matrix
作者:Brad Neuberg;boool
原文地址:http://www.onjava.com/pub/a/onjava/2005/10/26/ajax-handling-bookmarks-and-back-button.html
中文地址:http://www.matrix.org.cn/resource/article/43/43972_AJAX.html

资源

·onjava.com:onjava.com

·Matrix-Java开发者社区:http://www.matrix.org.cn/

·Download all sample code for this article.
http://www.onjava.com/onjava/2005/10/26/examples/downloads/examples.zip

·Download the Really Simple History framework.