Safari 中的页面转换效果? [英] Page transitions effects in Safari?

查看:53
本文介绍了Safari 中的页面转换效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Safari 中为网页添加类似于 IE 的页面转换效果?

How can I add Page transitions effects like IE in Safari for web pages?

推荐答案

你可以看看这个例子:http://sachiniscool.blogspot.com/2006/01/implementing-page-transitions-in.html.它描述了如何使用 AJAX 和 CSS 在 Firefox 中模拟页面转换.同样的方法也适用于 Safari.下面的代码取自该页面并稍微格式化:

You could check out this example: http://sachiniscool.blogspot.com/2006/01/implementing-page-transitions-in.html. It describes how to emulate page transitions in Firefox using AJAX and CSS. The same method works for Safari as well. The code below is taken from that page and slightly formatted:

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";
}

这篇关于Safari 中的页面转换效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆