关键问题-在部署实时站点之前在我的所有浏览器中进行测试都失败了……最佳实践-破碎了。
除了这一点,我有相当多的 javascript 运行一个我为我工作的公司管理的网站;我遇到的问题是 Javascript 在除 IE 之外的所有东西中都运行。
我已经比较了已经提到的其他一些问题(主要是在这里),但我找不到任何相关的东西。任何人的帮助都会很棒;该网站位于http://www.agpvideo.com
我相当确定问题存在于以下代码中的某处......
提前谢谢,我希望这能让我到达某个地方......
function ParseAjax(RootNode)
{
for(var i = 0; i < RootNode.childNodes.length; i++ )
{
var Node = RootNode.childNodes[i];
if( Node.nodeType == 3 || Node.nodeType == 8 )
{
continue;
}
else
{
if( console && console.log )
console.log("Parsing node: " + Node.nodeType + " :: " + Node.nodeName + " :: " + Node.className + " :: " + Node.id);
var Ajax = null;
if(( Ajax = Node.getAttribute("ajax")) == null )
{
if( RootNode.childNodes[i].childNodes != null && RootNode.childNodes[i].childNodes.length > 0 )
{
ParseAjax(RootNode.childNodes[i]);
continue;
}
else
{
continue;
}
}
else
{
if( Node.getAttribute("id") == null )
{
document.writeln("Invalid AJAX callback. Please consult an administrator.");
continue;
}
else
{
var Img = document.createElement("img");
var Src = document.createAttribute("src");
Src.value = "resource/img/std/ajax-loader-0.gif";
Img.setAttribute("src", Src.value);
Node.appendChild(Img);
RequestAjax(Node.getAttribute("id"), Ajax);
continue;
}
}
}
}
}
// JavaScript Document
function RequestAjax(ElementId,AjaxRequest)
{
if( ElementId.length <= 0 )
{
return;
}
else if( AjaxRequest.length <= 0 )
{
return;
}
else
{
if( console && console.log )
console.log("Preparing AJAX request...");
var Request = null;
if( window.XMLHttpRequest )
{
Request = new XMLHttpRequest();
}
else
{
Request = new ActiveXObject("Microsoft.XMLHTTP");
}
Request.ElementId = ElementId;
Request.onreadystatechange=function()
{
if( console && console.log )
{
if( Request.readyState <= 1)
console.log("AJAX state change: " + Request.readyState);
else
console.log("AJAX state change: " + Request.readyState + "/" + Request.status);
}
if( Request.readyState == 4 && Request.status == 200 )
{
var TargetElement = null;
if(( TargetElement = document.getElementById(Request.ElementId)) == null )
{
if( console && console.log )
console.log("AJAX TargetElement is null. Cannot set content for " + Request.ElementId);
}
else
{
TargetElement.innerHTML = Request.responseText;
ParseAjax(TargetElement);
}
}
}
Request.open("GET",AjaxRequest,true);
Request.send();
}
}