2008-09-19 33 views

回答

2

你可以看看這個例子:http://sachiniscool.blogspot.com/2006/01/implementing-page-transitions-in.html。它描述瞭如何使用AJAX和CSS在Firefox中模擬頁面轉換。同樣的方法也適用於Safari。下面的代碼是從頁採取略有格式:

var xmlhttp; 
var timerId = 0; 
var op = 1; 

function getPageFx() { 
    url = "/transpage2.html"; 
    if (window.XMLHttpRequest) { 
    xmlhttp = new XMLHttpRequest() 
    xmlhttp.onreadystatechange=xmlhttpChange 
    xmlhttp.open("GET",url,true) 
    xmlhttp.send(null) 
    } else getPageIE(); 
} 

function xmlhttpChange() { 
// if xmlhttp shows "loaded" 
    if (xmlhttp.readyState == 4) { 
    // if "OK" 
    if (xmlhttp.status == 200) { 
     if (timerId != 0) 
     window.clearTimeout(timerId); 
     timerId = window.setTimeout("trans();",100); 
    } else { 
     alert(xmlhttp.status) 
    } 
    } 
} 

function trans() { 
    op -= .1; 
    document.body.style.opacity = op; 
    if(op < .4) { 
    window.clearTimeout(timerId); 
    timerId = 0; document.body.style.opacity = 1; 
    document.open(); 
    document.write(xmlhttp.responseText); 
    document.close(); 
    return; 
    } 
    timerId = window.setTimeout("trans();",100); 
} 

function getPageIE() { 
    window.location.href = "transpage2.html"; 
} 
+0

在所有瀏覽器中的行爲Firefox 5不會更改IE轉換所在的頁面URL。在Chrome 12和Safari 5.1中,瀏覽器會跳過第一頁並轉到該頁面的引薦來源。這雖然在FireFox中有效。此測試是通過此答案中引用的原始URL執行的,而不是上面粘貼的代碼。 – 2011-08-03 15:20:14

1

退房Scriptaculous。如果這就是你所指的,就避免使用IE-JS(不知道你的意思是什麼樣的效果)。