Similar to the navigation in the MSN pop-up window

Source: Internet
Author: User

<Script language = 'javascript '>

VaR isie =! (Navigator. useragent. indexof ('msie ') =-1 );

VaR news;

VaR curnew = 0;

VaR timer;

Function Init (PIC, txt)

{

If (! PIC) PIC = "newspic ";

If (! TXT) TXT = "newspictxt ";

VaR text = Document. getelementbyid (txt );

 

VaR DIV = Document. getelementbyid (PIC );

If (! Div) return;

VaR nav = Document. createelement ("Div ");

Nav. classname = "nav ";

VaR nodes;

If (isie)

{

Nodes = div. childnodes;

}

Else

{

Nodes = childrennodes (Div. childnodes );

}

News = new array (nodes. Length );

For (VAR I = nodes. Length-1; I> = 0; I --)

{

VaR element = nodes [I];


 


News [I] = {};

News [I]. Element = element;

News [I]. Text = element. getattribute ("title ");

News [I]. url = element. getattribute ("href ");


VaR n = Document. createelement ("span ");

N. innerhtml = "<a herf = \" javascript:; \ "onclick = \" javascript: curnew = "+ (I-1) +"; change ('"+ PIC + "', '"+ TXT +"'); \ ">" + (I + 1) + "</a> ";

If (I = curnew)

{

N. classname = "cur ";

Text. innerhtml = "<a href = \" "+ news [I]. URL + "\" Title = \ "" + news [I]. text + "\" target = \ "_ blank \"> "+ news [I]. text + "</a> ";

}

Else

{

N. classname = "normal ";

}

Nav. appendchild (N );


News [I]. linkelement = N;

}

Div. appendchild (NAV );

Curnew --;

Window. setTimeout ("Change ('" + PIC + "', '" + TXT + "')", 3000 );

 

}

Function childrennodes (node)

{

VaR c = new array ();

For (VAR I = 0; I <node. length; I ++)

{

If (node [I]. nodename. tolowercase () = "")

C. Push (node [I]);

}

Return C;

}

Function Change (PIC, txt)

{

VaR DIV = Document. getelementbyid (PIC );

VaR text = Document. getelementbyid (txt );

If (! Div) return;

Curnew = curnew + 1;

If (curnew> = News. Length) curnew = 0;

For (VAR I = 0; I <news. length; I ++)

{

If (I = curnew)

{

News [I]. element. style. Display = "Block ";

News [I]. element. style. Visibility = "visible ";

News [I]. linkelement. classname = "cur ";

Text. innerhtml = "<a href = \" "+ news [I]. URL + "\" Title = \ "" + news [I]. text + "\" target = \ "_ blank \"> "+ news [I]. text + "</a> ";

}

Else

{

News [I]. element. style. Visibility = "hidden ";

News [I]. element. style. Display = "NONE ";

News [I]. linkelement. classname = "normal ";

}

}

If (timer) window. cleartimeout (timer );

Timer = Window. setTimeout ("Change ('" + PIC + "', '" + TXT + "')", 20000 );

 

}

 

</SCRIPT>

 

<Div
Id = "newspictxt"> </div>

<Div
Id = "newspic"
Style = "width: 285px; overflow: hidden;"> <
Title = "Snow Disaster, life is so fragile"
Style = "display: block; visibility: visible; text-Decoration: none ;"
Href = "http://cache.tianya.cn/publicforum/content/no04/1/679181.shtml"
Target = "_ blank">

Border = "0"
Class = "picture"
Height = "180"
Alt = "Snow Disaster, life is so fragile"
Src = "http://pic.yupoo.com/fatco/579624ff59bd/gk422jvg.jpg"

Width = "280"/> </a> <
Title = "mainstream Symbian OS global smartphone platforms"
Style = "display: none; visibility: hidden; text-Decoration: none ;"
Href = "http://z.csdn.net/adclick.php? Bannerid = 459"
Target = "_ blank"> Border = "0"

Class = "picture"
Height = "180"
Alt = "Symbian OS mainstream global smartphone platforms"

Src = "280180hyllecheng.jpg"
Width = "280"/> </a> <
Title = "Solaris 10 download"
Style = "display: none; visibility: hidden; text-Decoration: none ;"
Href = "http://z.csdn.net/adclick.php? Bannerid = 401"
Target = "_ blank"> Border = "0"

Class = "picture"
Height = "180"
Alt = "Solaris 10 download"
Src = "296196solaris.jpg"

Width = "280"/> </a> <
Title = "vote for your" Taurus! "
Style = "display: none; visibility: hidden; text-Decoration: none ;"
Href = "http://z.csdn.net/adclick.php? Bannerid = 410"
Target = "_ blank"> Border = "0"

Class = "picture"
Height = "180"
Alt = "vote for the Taurus in your heart! "

Src = "280180wulipingxuan.gif"
Width = "280"/> </a> <
Title = "2007 excellent programmer"
Style = "display: none; visibility: hidden; text-Decoration: none ;"
Href = "http://z.csdn.net/adclick.php? Bannerid = 369"
Target = "_ blank"> Border = "0"

Class = "picture"
Height = "180"
Alt = "2007 excellent programmer"
Src = "280187jinghua.gif"

Width = "280"/> </a> </div>


<Script
Type = "text/JavaScript">

Init ();


</SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.