当前位置:首页 > 开发教程 > ajax教程 >

AJAX:如何处理书签和后退按钮(2)

时间:2013-04-24 23:54 来源:网络整理 作者:采集侠 收藏

window.onload = initialize; function initialize() { // initialize the DHTML History // framework dhtmlHistory.initialize(); // subscribe to DHTML history change // events dhtmlHistory.addListener(his

window.onload = initialize;

function initialize() {
 // initialize the DHTML History
 // framework
 dhtmlHistory.initialize();

 // subscribe to DHTML history change
 // events
 dhtmlHistory.addListener(historyChange);

 // if this is the first time we have
 // loaded the page...
 if (dhtmlHistory.isFirstLoad()) {
  debug("Adding values to browser " + "history", false);
  // start adding history
  dhtmlHistory.add("helloworld", "Hello World Data");
  dhtmlHistory.add("foobar", 33);
  dhtmlHistory.add("boobah", true);

  var complexObject = new Object();
  complexObject.value1 = "This is the first value";
  complexObject.value2 = "This is the second data";
  complexObject.value3 = new Array();
  complexObject.value3[0] = "array 1";
  complexObject.value3[1] = "array 2";

  dhtmlHistory.add("complexObject", complexObject);


  在add()被调用之后,新的地址将立即作为一个锚值(链接地址)显示在浏览器的URL地址栏中。例如,对地址为的AJAX Web页面调用dhtmlHistory.add("helloworld", "Hello World Data")之后,用户将会在其浏览器URL地址栏中看到如下的地址:

  #helloworld

  然后用户可以将这个页面做成书签,如果以后用到这个书签,AJAX应用程序可以读取#helloworld值,并用它来初始化Web页面。散列后面的地址值是RSH框架可以透明编码和解码的URL地址。


ajax教程阅读排行

最新文章