gpt4 book ai didi

safari - Safari 中的页面转换效果?

转载 作者:行者123 更新时间:2023-12-01 03:02:02 30 4
gpt4 key购买 nike

如何在 Safari 中为网页添加 IE 等页面转换效果?

最佳答案

你可以看看这个例子: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";
}

关于safari - Safari 中的页面转换效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/101877/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com