Javascript文件“FASW过渡”复制我的标题信息。怎么修

时间:2013-02-13 12:07:28

标签: javascript jquery html5 wordpress css3

确定!我正在使用wordpress网站,这个javascript添加的所有内容都应该这样做,它确实...但是,当我通过safari开发检查元素时,我注意到它正在加载我的所有标题脚本,元,样式等进入身体以及头部。我无法弄清楚为什么。这是脚本的样子:

function ft(params) {

var ol= document.addEventListener?"DOMContentLoaded":"load"; //on load event
var navB = params.navB || "reverse slide"; //backbrowser button effect, default empty
var but = params.but || false; //Allow transitions on input type button
var cBa = params.cBa || function() {};

function aDL(url, t, o) {   //Ajax Div Load
  if (window.XMLHttpRequest) {
    r = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    r = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (r != undefined) {
    r.onreadystatechange = function() {Ol(r, t, o);};
    r.open("GET", url, true);
    r.send("");
  }
}  
function Ol(r, t, o) {  //On load div
  if (r.readyState == 4) { 
    if (r.status == 200 || r.status == 0) { 
      t.innerHTML = r.responseText;
      o();
    } else {
      t.innerHTML="Error:\n"+ r.status + "\n" +r.statusText;
    }
  }
}

    function DE()       //Div Effect
{
var dochtml = document.body.innerHTML;
document.body.innerHTML = "";
var d1 = document.createElement("div");
d1.id = "d1";
d1.style.zIndex = 2;
d1.style.position = "absolute"; 
d1.style.width = "100%"; 
d1.style.height = "100%"; 
d1.style.left = "0px"; 
d1.style.top = "0px";
document.body.appendChild(d1);
d1.innerHTML = dochtml;
var d2 = document.createElement("div");
d2.id = "d2";
d2.style.zIndex = 1;
d2.style.position = "absolute"; 
d2.style.width = "100%"; 
d2.style.height = "100%"; 
d2.style.left = "0px"; 
d2.style.top = "0px";
document.body.appendChild(d2);
return {d1: d1, d2: d2 };
}

function timeOuts(e, d1,d2)
{
setTimeout(function() { d1.className = e + " out"; }, 1);
setTimeout(function() { d2.className = e + " in"; }, 1);
setTimeout(function() { 
    document.body.innerHTML = d2.innerHTML;
    cBa();
}, 706);
}

function slideTo(href, effect, pushstate)
{
var d = DE();
var d1 = d.d1;
var d2 = d.d2;
aDL(href, d2, 
function() {
if (pushstate && window.history.pushState) window.history.pushState("", "", href);
            timeOuts(effect,d1,d2);
        }
);
}
function dC(e){ //Detect click event
var o;
var o=e.srcElement || e.target;
var tn = o.tagName.toLowerCase();
if (!but || tn!="input" || o.getAttribute("type")!="button")    //if it is not a button
{
    //try to find an anchor parent
    while (tn!=="a" && tn!=="body")
    {
        o = o.parentNode;
        tn = o.tagName.toLowerCase();
    }
    if (tn==="body") return;
}
var t = o.getAttribute("data-ftrans");
if (t) 
{
    e.preventDefault();
    var hr = o.getAttribute("href") || o.getAttribute("data-href");
    if (hr) slideTo(hr, t, true);
}
}
function aE(ev, el, f) {  //Add event
if (el.addEventListener)  // W3C DOM
    el.addEventListener(ev,f,false);
else if (el.attachEvent) { // IE DOM
     var r = el.attachEvent("on"+ev, f);
     return r;
}
}
aE("click", window, dC);

aE(ol, document,        //On load
function(ev)
{
aE("popstate", window, function(e) {    //function to reload when back button   is clicked
        slideTo(location.pathname, navB, false);
});
}

);


}

此处是指向该网站的链接:http://www.fasw.ws/faswwp/non-jquery-page-transitions-lightweight/

我认为那不应该发生。因此,我试图找出如何保持清洁,并保持头文件加载在头部,并只加载页面内容。我无法想出这个,需要专业人士的帮助:))

1 个答案:

答案 0 :(得分:0)

FASW附带两个函数,在初始化组件之前和之后都充当“钩子”。你可以这样做:

(function inittrans() 
{
    initComponents();
    var params = { /*put your options here*/ };
    new ft(params);
})();

function onTransitionFinished()
{
    initComponents();
}

function initComponents() {
    // here is where you put your "other" javascript codes
}

注意在加载初始页面后如何执行javascript代码,并在转换发生后再次执行。无论如何,这就是我如何解决这个问题'因为它们无法正常运行,因为它们是由FASW通过Ajax在运行中加载的。