欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
用AJAX來(lái)控制書(shū)簽和回退按鈕
用AJAX來(lái)控制書(shū)簽和回退按鈕

作者:Brad Neuberg

譯者:boool


版權聲明:任何獲得Matrix授權的網(wǎng)站,轉載時(shí)請務(wù)必以超鏈接形式標明文章原始出處和作者信息及本聲明
作者: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
關(guān)鍵詞: ajax;bookmarks;back button


這篇文章描述了一個(gè)支持AJAX應用書(shū)簽和回退按鈕的開(kāi)源的javascript庫。在這個(gè)指南的最后,開(kāi)發(fā)者將會(huì )得出一個(gè)甚至不是Google Maps 或者 Gmail那樣處理的AJAX的解決方案:健壯的,可用的書(shū)簽和向前向后的動(dòng)作能夠象其他的web頁(yè)面一樣正確的工作。

AJAX:怎樣去控制書(shū)簽和回退按鈕 這篇文章說(shuō)明了一個(gè)重要的成果,AJAX應用目前面對著(zhù)書(shū)簽和回退按鈕的應用,描述了非常簡(jiǎn)單的歷史庫(Really Simple History),一個(gè)開(kāi)源的解決這類(lèi)問(wèn)題的框架,并提供了一些能夠運行的例子。

這篇文章描述的主要問(wèn)題是雙重的,一是一個(gè)隱藏的html 表單被用作一個(gè)大而短生命周期的客戶(hù)端信息的session緩存,這個(gè)緩存對在這個(gè)頁(yè)面上前進(jìn)回退是強壯的。二是一個(gè)錨連接和隱藏的iframes的組合用來(lái)截取和記錄瀏覽器的歷史事件,來(lái)實(shí)現前進(jìn)和回退的按鈕。這兩個(gè)技術(shù)都被用一個(gè)簡(jiǎn)單的javascript庫來(lái)封裝,以利于開(kāi)發(fā)者的使用。

存在的問(wèn)題
書(shū)簽和回退按鈕在傳統的多頁(yè)面的web應用上能順利的運行。當用戶(hù)在網(wǎng)站上沖浪時(shí),他們的瀏覽器地址欄能更新URL,這些URL可以被粘貼到的email或者添加到書(shū)簽以備以后的使用?;赝撕颓斑M(jìn)按鈕也可以正常運行,這可以使用戶(hù)在他們訪(fǎng)問(wèn)的頁(yè)面間移動(dòng)。

AJAX應用是與眾不同的,然而,他也是在單一web頁(yè)面上成熟的程序。瀏覽器不是為AJAX而做的—AJAX他捕獲過(guò)去的事件,當web應用在每個(gè)鼠標點(diǎn)擊時(shí)刷新頁(yè)面。

在象Gmail那樣的AJAX軟件里,瀏覽器的地址欄正確的停留就象用戶(hù)在選擇和改變應用的狀態(tài)時(shí),這使得作書(shū)簽到特定的應用視圖里變得不可能。此外,如果用戶(hù)按下了他們的回退按鈕去返回上一個(gè)操作,他們會(huì )驚奇的發(fā)現瀏覽器將完全離開(kāi)原來(lái)他所在的應用的web頁(yè)面。

解決方案
開(kāi)源的Really Simply History(RSH)框架解決了這些問(wèn)題,他帶來(lái)了AJAX應用的作書(shū)簽和控制前進(jìn)后退按鈕的功能。RSH目前還是beta版,在Firefox1.0上,Netscape7及以上,和IE6及以上運行。Safari現在還不支持(要得到更詳細的說(shuō)明,請看我的weblog中的文章Coding in Paradise: Safari: No DHTML History Possible).

目前存在的幾個(gè)AJAX框架可以幫助我們做書(shū)簽和發(fā)布歷史,然而所有的框架都因為他們的實(shí)現而被幾個(gè)重要的bug困擾(請看Coding in Paradise: AJAX History Libraries 得知詳情)。此外,許多AJAX歷史框架集成綁定到較大的庫上,比如Backbase 和 Dojo,這些框架提供了與傳統AJAX應用不同的編程模型,強迫開(kāi)發(fā)者去采用一整套全新的方式去獲得瀏覽器的歷史相關(guān)的功能。

相應的,RSH是一個(gè)簡(jiǎn)單的模型,能被包含在已經(jīng)存在的AJAX系統中。而且,Really Simple History庫使用了一些技巧去避免影響到其他歷史框架的bug.

Really Simple History框架由2個(gè)javascript類(lèi)庫組成,分別叫DhtmlHistory 和 HistoryStorage.

DhtmlHistory 類(lèi)提供了一個(gè)對AJAX應用提取歷史的功能。.AJAX頁(yè)面add() 歷史事件到瀏覽器里,指定新的地址和關(guān)聯(lián)歷史數據。DhtmlHistory 類(lèi)用一個(gè)錨的hash表更新瀏覽器現在的URL,比如#new-location ,然后用這個(gè)新的URL關(guān)聯(lián)歷史數據。AJAX應用注冊他們自己到歷史監聽(tīng)器里,然后當用戶(hù)用前進(jìn)和后退按鈕導航的時(shí)候,歷史事件被激發(fā),提供給瀏覽器新的地址和調用add()持續保留數據。

第二個(gè)類(lèi)HistoryStorage,允許開(kāi)發(fā)者存儲任意大小的歷史數據。一般的頁(yè)面,當一個(gè)用戶(hù)導航到一個(gè)新的網(wǎng)站,瀏覽器會(huì )卸載和清除所有這個(gè)頁(yè)面的應用和javascript狀態(tài)信息。如果用戶(hù)用回退按鈕返回過(guò)來(lái)了,所有的數據已經(jīng)丟失了。HistoryStorage 類(lèi)解決了這個(gè)問(wèn)題,他有一個(gè)api 包含簡(jiǎn)單的hashtable方法比如put(),get(),hasKey()。這些方法允許開(kāi)發(fā)者在離開(kāi)web頁(yè)面時(shí)存儲任意大小的數據,當用戶(hù)點(diǎn)了回退按鈕返回時(shí),數據可以通過(guò)HistoryStorage 類(lèi)被訪(fǎng)問(wèn)。我們通過(guò)一個(gè)隱藏的表單域(a hidden form field),利用瀏覽器即使在用戶(hù)離開(kāi)web頁(yè)面也會(huì )自動(dòng)保存表單域值的這個(gè)特性,完成這個(gè)功能。

讓我們立即進(jìn)入一個(gè)簡(jiǎn)單的例子吧。

示例1
首先,任何一個(gè)想使用Really Simple History框架的頁(yè)面必須包含(include)dhtmlHistory.js 腳本。

<!-- Load the Really Simple 
     History framework -->
<script type="text/javascript"
        src="../../framework/dhtmlHistory.js">
</script>


DHTML History 應用也必須在和AJAX web頁(yè)面相同的目錄下包含一個(gè)叫blank.html 的指定文件,這個(gè)文件被Really Simple History框架綁定而且對IE來(lái)說(shuō)是必需的。另一方面,RSH使用一個(gè)hidden iframe 來(lái)追蹤和加入IE歷史的改變,為了正確的執行功能,這個(gè)iframe需要指向一個(gè)真正的地址,不需要blank.html。

RSH框架創(chuàng )建了一個(gè)叫dhtmlHistory 的全局對象,作為操作瀏覽器歷史的入口。使用dhtmlHistory 的第一步需要在頁(yè)面加載后初始化這個(gè)對象。

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


然后,開(kāi)發(fā)者使用dhtmlHistory.addListener()方法去訂閱歷史改變事件。這個(gè)方法獲取一個(gè)javascript回調方法,當一個(gè)DHTML歷史改變事件發(fā)生時(shí)他將收到2個(gè)自變量,新的頁(yè)面地址,和任何可選的而且可以被關(guān)聯(lián)到這個(gè)事件的歷史數據。

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


historyChange()方法是簡(jiǎn)單易懂得,它是由一個(gè)用戶(hù)導航到一個(gè)新地址后收到的新地址(newLocation)和一個(gè)關(guān)聯(lián)到事件的可選的歷史數據historyData 構成的。

/** Our callback to receive history change
     events. */
function historyChange(newLocation,
                       historyData) {
  debug("A history change has occurred: "
        + "newLocation="+newLocation
        + ", historyData="+historyData,
        true);
}


上面用到的debug()方法是例子代碼中定義的一個(gè)工具函數,在完整的下載例子里有。debug()方法簡(jiǎn)單的在web頁(yè)面上打一條消息,第2個(gè)Boolean變量,在代碼里是true,控制一個(gè)新的debug消息打印前是否要清除以前存在的所有消息。

一個(gè)開(kāi)發(fā)者使用add()方法加入歷史事件。加入一個(gè)歷史事件包括根據歷史的改變指定一個(gè)新的地址,就像"edit:SomePage"標記, 還提供一個(gè)事件發(fā)生時(shí)可選的會(huì )被存儲到歷史數據historyData值.

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()方法被調用后,新地址立刻被作為一個(gè)錨值顯示在用戶(hù)的瀏覽器的URL欄里。例如,一個(gè)AJAX web頁(yè)面停留在http://codinginparadise.org/my_ajax_app,調用了dhtmlHistory.add("helloworld", "Hello World Data" 后,用戶(hù)將在瀏覽器的URL欄里看到下面的地址
http://codinginparadise.org/my_ajax_app#helloworld

然后他們可以把這個(gè)頁(yè)面做成書(shū)簽,如果他們使用這個(gè)書(shū)簽,你的AJAX應用可以讀出#helloworld值然后使用她去初始化web頁(yè)面。Hash里的地址值被Really Simple History  框架顯式的編碼和解碼(URL encoded and decoded) (這是為了解決字符的編碼問(wèn)題)

對當AJAX地址改變時(shí)保存更多的復雜的狀態(tài)來(lái)說(shuō),historyData  比一個(gè)更容易的匹配一個(gè)URL的東西更有用。他是一個(gè)可選的值,可以是任何javascript類(lèi)型,比如Number, String, 或者 Object 類(lèi)型。有一個(gè)例子是用這個(gè)在一個(gè)多文本編輯器(rich text editor)保存所有的文本,例如,如果用戶(hù)從這個(gè)頁(yè)面漂移(或者說(shuō)從這個(gè)頁(yè)面導航到其他頁(yè)面,離開(kāi)了這個(gè)頁(yè)面)走。當一個(gè)用戶(hù)再回到這個(gè)地址,瀏覽器會(huì )把這個(gè)對象返回給歷史改變偵聽(tīng)器(history change listener)。

開(kāi)發(fā)者可以提供一個(gè)完全的historyData 的javascript對象,用嵌套的對象objects和排列arrays來(lái)描繪復雜的狀態(tài)。只要是JSON (JavaScript Object Notation)  允許的那么在歷史數據里就是允許的,包括簡(jiǎn)單數據類(lèi)型和null型。DOM的對象和可編程的瀏覽器對象比如XMLHttpRequest ,不會(huì )被保存。注意historyData 不會(huì )被書(shū)簽持久化,如果瀏覽器關(guān)掉,或者瀏覽器的緩存被清空,或者用戶(hù)清除歷史的時(shí)候,會(huì )消失掉。

使用dhtmlHistory 最后一步,是isFirstLoad() 方法。如果你導航到一個(gè)web頁(yè)面,再跳到一個(gè)不同的頁(yè)面,然后按下回退按鈕返回起始的網(wǎng)站,第一頁(yè)將完全重新裝載,并激發(fā)onload事件。這樣能產(chǎn)生破壞性,當代碼在第一次裝載時(shí)想要用某種方式初始化頁(yè)面的時(shí)候,不會(huì )再刷新頁(yè)面。isFirstLoad() 方法讓區別是最開(kāi)始第一次裝載頁(yè)面,還是相對的,在用戶(hù)導航回到他自己的瀏覽器歷史中記錄的網(wǎng)頁(yè)時(shí)激發(fā)load事件,成為可能。

在例子代碼中,我們只想在第一次頁(yè)面裝載的時(shí)候加入歷史事件,如果用戶(hù)在第一次裝載后,按回退按鈕返回頁(yè)面,我們就不想重新加入任何歷史事件。

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);


讓我們繼續使用historyStorage 類(lèi)。類(lèi)似dhtmlHistory ,historyStorage通過(guò)一個(gè)叫historyStorage的單一全局對象來(lái)顯示他的功能,這個(gè)對象有幾個(gè)方法來(lái)偽裝成一個(gè)hash table, 象put(keyName, keyValue), get(keyName), and hasKey(keyName).鍵名必須是字符,同時(shí)鍵值可以是復雜的javascript對象或者甚至是xml格式的字符。在我們源碼source code的例子中,我們put() 簡(jiǎn)單的XML  到historyStorage 在頁(yè)面第一次裝載時(shí)。

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);
                    
    // cache some values in the history
    // storage
    debug("Storing key ‘fakeXML‘ into "
          + "history storage", false);
    var fakeXML =
      ‘<?xml version="1.0" ‘
      +      ‘encoding="ISO-8859-1"?>‘
      +      ‘<foobar>‘
      +         ‘<foo-entry/>‘
      +      ‘</foobar>‘;
    historyStorage.put("fakeXML", fakeXML);
  }


然后,如果用戶(hù)從這個(gè)頁(yè)面漂移走(導航走)又通過(guò)返回按鈕返回了,我們可以用get()提出我們存儲的值或者用haskey()檢查他是否存在。

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);
                    
    // cache some values in the history
    // storage
    debug("Storing key ‘fakeXML‘ into "
          + "history storage", false);
    var fakeXML =
      ‘<?xml version="1.0" ‘
      +      ‘encoding="ISO-8859-1"?>‘
      +      ‘<foobar>‘
      +         ‘<foo-entry/>‘
      +      ‘</foobar>‘;
    historyStorage.put("fakeXML", fakeXML);
  }
  
  // retrieve our values from the history
  // storage
  var savedXML =
              historyStorage.get("fakeXML");
  savedXML = prettyPrintXml(savedXML);
  var hasKey =
           historyStorage.hasKey("fakeXML");
  var message =
    "historyStorage.hasKey(‘fakeXML‘)="
    + hasKey + "<br>"
    + "historyStorage.get(‘fakeXML‘)=<br>"
    + savedXML;
  debug(message, false);
}


prettyPrintXml() 是一個(gè)第一在例子源碼full example source code中的工具方法。這個(gè)方法準備簡(jiǎn)單的xml顯示在web page ,方便調試。

注意數據只是在使用頁(yè)面的歷史時(shí)被持久化,如果瀏覽器關(guān)閉了,或者用戶(hù)打開(kāi)一個(gè)新的窗口又再次鍵入了ajax應用的地址,歷史數據對這些新的web頁(yè)面是不可用的。歷史數據只有在用前進(jìn)或回退按鈕時(shí)才被持久化,而且在用戶(hù)關(guān)閉瀏覽器或清空緩存的時(shí)候會(huì )消失掉。想真正的長(cháng)時(shí)間的持久化,請看Ajax MAssive Storage System (AMASS).
我們的簡(jiǎn)單示例已經(jīng)完成。演示他(Demo it)或者下載全部的源代碼(download the full source code.)

示例2
我們的第2個(gè)例子是一個(gè)簡(jiǎn)單的模擬ajax email  應用的示例,叫O‘Reilly Mail,類(lèi)似Gmail. O‘Reilly Mail描述了怎樣使用dhtmlHistory類(lèi)去控制瀏覽器的歷史,和怎樣使用historyStorage對象去緩存歷史數據。

O‘Reilly Mail 用戶(hù)接口(user interface)有兩部分。在頁(yè)面的左邊是一個(gè)有不同email文件夾和選項的菜單,例如 收件箱,草稿,等等。當一個(gè)用戶(hù)選擇了一個(gè)菜單項,比如收件箱,我們用這個(gè)菜單項的內容更新右邊的頁(yè)面。在一個(gè)實(shí)際應用中,我們會(huì )遠程取得和顯示選擇的信箱內容,不過(guò)在O‘Reilly Mail里,我們簡(jiǎn)單的顯示選擇的選項。

O‘Reilly Mail使用Really Simple History 框架向瀏覽器歷史里加入菜單變化和更新地址欄,允許用戶(hù)利用瀏覽器的回退和前進(jìn)按鈕對應用做書(shū)簽和跳到上一個(gè)變化的菜單。

我們加入一個(gè)特別的菜單項,地址簿,來(lái)描繪historyStorage 能夠怎樣被使用。地址簿是一個(gè)由聯(lián)系的名字電子郵件和地址組成的javascript數組,在一個(gè)真實(shí)的應用里我們會(huì )取得他從一個(gè)遠程的服務(wù)器。不過(guò),在O‘Reilly Mail里,我們在本地創(chuàng )建這個(gè)數組,加入幾個(gè)名字電子郵件和地址,然后把他們存儲在historyStorage 對象里。如果用戶(hù)離開(kāi)了這個(gè)web頁(yè)面以后又返回的話(huà),O‘Reilly Mail應用重新從緩存里得到地址簿,勝過(guò)(不得不)再次訪(fǎng)問(wèn)遠程服務(wù)器。

地址簿是在我們的初始化initialize()方法里存儲和重新取得的

/** Our function that initializes when the page
    is finished loading. */
function initialize() {
   // initialize the DHTML History framework
   dhtmlHistory.initialize();
  
   // add ourselves as a DHTML History listener
   dhtmlHistory.addListener(handleHistoryChange);

   // if we haven‘t retrieved the address book
   // yet, grab it and then cache it into our
   // history storage
   if (window.addressBook == undefined) {
      // Store the address book as a global
      // object.
      // In a real application we would remotely
      // fetch this from a server in the
      // background.
      window.addressBook =
         ["Brad Neuberg ‘bkn3@columbia.edu‘",
          "John Doe ‘johndoe@example.com‘",
          "Deanna Neuberg ‘mom@mom.com‘"];
          
      // cache the address book so it exists
      // even if the user leaves the page and
      // then returns with the back button
      historyStorage.put("addressBook",
                         addressBook);
   }
   else {
      // fetch the cached address book from
      // the history storage
      window.addressBook =
               historyStorage.get("addressBook");
   }


處理歷史變化的代碼是簡(jiǎn)單的。在下面的代碼中,當用戶(hù)不論按下回退還是前進(jìn)按鈕handleHistoryChange 都被調用。我們得到新的地址(newLocation) 使用他更新我們的用戶(hù)接口來(lái)改變狀態(tài),通過(guò)使用一個(gè)叫displayLocation的O‘Reilly Mail的工具方法。

/** Handles history change events. */
function handleHistoryChange(newLocation,
                             historyData) {
   // if there is no location then display
   // the default, which is the inbox
   if (newLocation == "") {
      newLocation = "section:inbox";
   }
  
   // extract the section to display from
   // the location change; newLocation will
   // begin with the word "section:"
   newLocation =
         newLocation.replace(/section\:/, "");
  
   // update the browser to respond to this
   // DHTML history change
   displayLocation(newLocation, historyData);
}

/** Displays the given location in the
    right-hand side content area. */
function displayLocation(newLocation,
                         sectionData) {
   // get the menu element that was selected
   var selectedElement =
            document.getElementById(newLocation);
            
   // clear out the old selected menu item
   var menu = document.getElementById("menu");
   for (var i = 0; i < menu.childNodes.length;
                                          i++) {
      var currentElement = menu.childNodes[i];
      // see if this is a DOM Element node
      if (currentElement.nodeType == 1) {
         // clear any class name
         currentElement.className = "";
      }                                      
   }
  
   // cause the new selected menu item to
   // appear differently in the UI
   selectedElement.className = "selected";
  
   // display the new section in the right-hand
   // side of the screen; determine what
   // our sectionData is
  
   // display the address book differently by
   // using our local address data we cached
   // earlier
   if (newLocation == "addressbook") {
      // format and display the address book
      sectionData = "<p>Your addressbook:</p>";
      sectionData += "<ul>";
      
      // fetch the address book from the cache
      // if we don‘t have it yet
      if (window.addressBook == undefined) {
         window.addressBook =
               historyStorage.get("addressBook");
      }
      
      // format the address book for display
      for (var i = 0;
               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的源代碼。

結束語(yǔ)
你現在已經(jīng)學(xué)習了使用Really Simple History API 讓你的AJAX應用響應書(shū)簽和前進(jìn)回退按鈕,而且有代碼可以作為創(chuàng )建你自己的應用的素材。我熱切地期待你利用書(shū)簽和歷史的支持完成你的AJAX創(chuàng )造。

資源
·onjava.com:onjava.com
·Matrix-Java開(kāi)發(fā)者社區:http://www.matrix.org.cn/
·Download all sample code for this article.
·Download the Really Simple History framework.
·Demo O‘Reilly Mail or download the O‘Reilly Mail source code. The full example download also includes more examples for you to play with.
·Coding in Paradise: The author‘s weblog, covering AJAX, DHTML, and Java techniques and new developments in collaborative technologies, such as WikiWikis.


感謝
特別的要感謝每個(gè)檢閱這篇文章的the Really Simple History框架的人:
Michael Eakes, Jeremy Sevareid, David Barrett, Brendon Wilson, Dylan Parker, Erik Arvidsson, Alex Russell, Adam Fisk, Alex Lynch, Joseph Hoang Do, Richard MacManus, Garret Wilson, Ray Baxter, Chris Messina, and David Weekly.
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
功能測試注意要點(diǎn)
JS: 打開(kāi)新窗口時(shí)(open window),使用傳遞post參數
Web測試的一些經(jīng)驗
ajax與HTML5 history pushState/replaceState實(shí)例
哈希路由(hash模式)和歷史路由(history模式)的區別
history.go(-1)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久