| function get_table_link ( $title, $start, $step ) { $link = "myHistory.addResource('table-$start-$step'); " ."x_get_table($start, $step, to_window); " ."return false;"; return '<a href="#" >' . $title.'</a>'; } function get_image_link ( $title, $index ) { $link = "myHistory.addResource('image-$index'); " ."x_get_image($index, to_window); " ."return false;"; return '<a href="#" >' . $title .'</a>'; } |
| display_history_buttons(); |
| function display_history_buttons() { var str = ''; if (myHistory.hasPrev()) { str += '<a href="#" > <img src="/html/UploadPic/2007-12/20071210221248267.gif" alt="Back" /></a>'; } else { str += '<img src="/html/UploadPic/2007-12/20071210221248995.gif" alt="" />'; } if (myHistory.hasNext()) { str += '<a href="#" > <img src="/html/UploadPic/2007-12/20071210221248649.gif" alt="Forward" /></a>'; } else { str += '<img src="/html/UploadPic/2007-12/20071210221248452.gif" alt="" />'; } str += '<a href="#" > <img src="/html/UploadPic/2007-12/20071210221248853.gif" alt="Reload" /></a>'; document.getElementById("historybuttons").innerHTML = str; } |
| function load_current() { // No existing history. if (myHistory.stack.length == 0) { x_get_table(to_window); myHistory.addResource('table-0-5'); // Load from history. } else { var current = myHistory.getCurrent(); var params = current.split('-'); if (params[0] == 'table') { x_get_table(params[1], params[2], to_window); } else if (params[0] == 'image') { x_get_image(params[1], to_window); } } } |
| window.onload = function () { load_current(); }; |
| function do_back() { myHistory.go(-1); load_current(); } function do_forward() { myHistory.go(1); load_current(); } function do_reload() { myHistory.go(0); } |
图 3. 与相册应用程序结合的历史记录按钮 |
| CHCurrent = 4 CHStack = table-0-5%2Cimage-1%2Cimage-2%2Cimage-3%2Ctable-3-5 |