Safari中的页面转换效果?

Safari中的页面转换效果?,safari,Safari,如何在Safari for web pages中添加类似IE的页面转换效果?您可以查看以下示例:。它描述了如何使用AJAX和CSS在Firefox中模拟页面转换。同样的方法也适用于Safari。下面的代码取自该页并略加格式化: var xmlhttp; var timerId = 0; var op = 1; function getPageFx() { url = "/transpage2.html"; if (window.XMLHttpRequest) { xmlhttp

如何在Safari for web pages中添加类似IE的页面转换效果?

您可以查看以下示例:。它描述了如何使用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";
}
var-xmlhttp;
var-timerId=0;
var-op=1;
函数getPageFx(){
url=“/transpage2.html”;
if(window.XMLHttpRequest){
xmlhttp=newxmlhttprequest()
xmlhttp.onreadystatechange=xmlhttpChange
open(“GET”,url,true)
xmlhttp.send(空)
}else getPageIE();
}
函数xmlhttpChange(){
//如果xmlhttp显示“已加载”
if(xmlhttp.readyState==4){
//如果“确定”
if(xmlhttp.status==200){
if(timerId!=0)
clearTimeout(timerId);
timerId=window.setTimeout(“trans();”,100);
}否则{
警报(xmlhttp.status)
}
}
}
函数trans(){
op-=.1;
document.body.style.opacity=op;
如果(op<.4){
clearTimeout(timerId);
timerId=0;document.body.style.opacity=1;
document.open();
document.write(xmlhttp.responseText);
document.close();
返回;
}
timerId=window.setTimeout(“trans();”,100);
}
函数getPageIE(){
window.location.href=“transpage2.html”;
}

退房。如果你指的是IE Only JS(不知道你指的是什么效果)。

在所有浏览器中,Firefox 5的行为都是它不会改变IE转换的页面URL。在Chrome 12和Safari 5.1中,浏览器向后跳过第一页并转到该页的参考者。不过,这在FireFox中确实有效。此测试是通过此答案中引用的原始URL执行的,而不是上面粘贴的代码。