The XML structure is as follows
Copy Code code as follows:
<ad>
<tupian>http://www.seehaha.com/images/060901-150.100.2.gif</tupian>
<tupian>http://www.seehaha.com/xml/061009-300.100.jpg</tupian>
<dizhi>http://www.seehaha.com/plan/</dizhi>
<dizhi>http://www.seehaha.com/va.htm</dizhi>
</ad>
==
JScript files
var now = new Date ();
var Min = Now.getseconds ();
var i;
if (Min% 2) = = 1)
Read the number of seconds, depending on the parity random rotation, of course, you can also change the algorithm to increase the XML node points
{
i = 1;
}
Else
{i = 0; }
var url = "Xml/ads.xml";
String.prototype.Trim = function () {
Return This.replace (/(^\s*) | ( \s*$)/g, "");
}
var xmldoc;
To determine whether Firefox or IE
var Moz = (typeof document.implementation!= ' undefined ') && (typeof document.implementation.createDocument '!= ') Undefined ');
var ie = (typeof window.) ActiveXObject!= ' undefined ');
function ImportXML (file) {
if (Moz)
{
xmldoc = Document.implementation.createDocument ("", "Doc", NULL);
Create Firefox under XML Document Object
}
else if (IE)
{xmldoc = new ActiveXObject ("MSXML2. domdocument.3.0 ");
Xmldoc.async = false;
while (Xmldoc.readystate!= 4) {};
Create an IE XML Document object
}
Xmldoc.load (file);
}importxml (URL);/load XML
function Updatetupiandizhi ()
{
if (Moz)
{
var ad = Xmldoc.getelementsbytagname ("ad") [0];
var Tupian;
var _tupian = ad.getelementsbytagname ("Tupian") [I].firstchild.nodevalue;
if (_tupian) Tupian = _tupian. Trim ();
Get the value under the Tupian,dizhi node
var Dizhi;
var _dizhi=ad.getelementsbytagname ("Dizhi") [I].firstchild.nodevalue;
if (_dizhi) Dizhi = _dizhi. Trim ();
document.getElementById (' Tupian '). href = Tupian;
document.getElementById (' Dizhi '). src = Dizhi;
Achieve rotation
else if (IE)
{var src = xmlDoc.documentElement.selectNodes ("Tupian");
var href = xmlDoc.documentElement.selectNodes ("Dizhi");
Get the value under the Tupian,dizhi node
document.getElementById ("Dizhi"). href = href (i). text;
document.getElementById ("Tupian"). src = src (i). text;
Achieve rotation
}}