62、文字链接说明展开

62、文字链接说明展开

脚本说明:

把如下代码加入<body>区域中

<style>

<!--

 

#tickerarea{

border:1px solid black;

}

 

#expandbutton{

background-color:white;

width:100px;

}

 

.expandmenu{

position:absolute;

width:250px;

border:1px solid black;

background-color:white;

visibility:hidden;

z-index:50;

}

 

.expandmenu a{

text-decoration:none;

font: normal 14px default;

}

 

.expandmenu_highlight{

background-color:lightyellow;

}

 

-->

</style>

<script language="JavaScript1.2">

 

//configure tickercontents[] to set the messges you wish be displayed (HTML codes accepted)

var tickercontents=new Array()

tickercontents[0]='欢迎你光临网页制作的优秀网站 <a href="http://www.7stk.com">网页特效代码</a> 希望你能有更多的收获!'

tickercontents[1]='欢迎你光临国内最大的娱乐类网站 <a href="http://www.163.com">网易</a> 希望你能有更多的收获!'

tickercontents[2]='欢迎你光临国内最大的搜索类网站 <a href="http://www.7syg.com">搜狐</a> 希望你能有更多的快乐!'

 

//specify how many characters of a message (for each msg) to show in expanded menu:

var charslimit=30

 

//Below specifies the "expand text". Do not remove onClick=".." portion.

var expandtext='<a href="#" onClick="dropdownit(event);return false">展开</a> <img src="tridown.gif" border=0>'

 

//configure below variables to set dimensions and main color of the ticker

var tickerwidth='275px'

var tickerheight='75px' //not including "Expand" text

var tickerbgcolor='#DDDDFF'

 

//configure the below variable to determine the delay between ticking of messages (in miliseconds)

var tickdelay=2500

 

////Do not edit pass this line////////////////

 

var ie4=document.all || navigator.userAgent.search(/opera.7/i)!=-1 //lump Opera 7 with IE

var ns6=document.getElementById && !document.all && !window.opera

var ns4=document.layers

 

if (ns4){

expandtext=expandtext.replace(/dropdownit\(event\); *return false/gi, "return dropdownitNS4(event,this)")

tickerheightNS4=parseInt(tickerheight)+19

tickerlistheightNS4=tickerheight

}

 

var currentmessage=0

var tickercontentstotal=''

 

if (ie4||ns6) //OUTPUT DROP DOWN MENU

document.write('<div id="tickerexpand" class="expandmenu" style="visibility:hidden"></div>')

 

function rotatecontent(){

if (ns4){ //OUTPUT HTML for ticker area for NS4

tickerobj.document.tickernssub.document.write(tickercontents[currentmessage]+'')

tickerobj.document.tickernssub.document.close()

}

else if (ie4||ns6){

tickerobj.innerHTML=tickercontents[currentmessage]

previousmessage=(currentmessage==0)? tickercontents.length-1 : currentmessage-1

tickerexpand_item=ns6? document.getElementById("expand"+currentmessage) : eval("expand"+currentmessage)

tickerexpand_previousitem=ns6? document.getElementById("expand"+previousmessage) : eval("expand"+previousmessage)

tickerexpand_previousitem.className=""

tickerexpand_item.className="expandmenu_highlight"

}

currentmessage=(currentmessage==tickercontents.length-1)? 0 : currentmessage+1

rotatemsgtimer=setTimeout("rotatecontent()",tickdelay)

}

 

function dropdownit(e){

if (ns6) e.stopPropagation()

else e.cancelBubble=true

tickerexpandobj.style.visibility=tickerexpandobj.style.visibility=="hidden"? "visible" : "hidden"

expandbuttonLeft=ns6? e.pageX-e.layerX : document.body.scrollLeft+event.clientX-event.offsetX

expandbuttonTop=ns6? e.pageY-e.layerY : document.body.scrollTop+event.clientY-event.offsetY

tickerexpandobj.style.left=expandbuttonLeft+"px"

tickerexpandobj.style.top=expandbuttonTop+expandbuttonobj.offsetHeight-3+"px"

}

 

function dropdownitNS4(e, currentobj){

tickerexpandobj.left=tickerobj.pageX

tickerexpandobj.top=tickerobj.pageY+parseInt(tickerlistheightNS4)+tickerobj.document.expandbuttonNS4.document.height

tickerexpandobj.visibility=(tickerexpandobj.visibility=="hide")? "show" : "hide"

return false

}

 

function jumptomsg(whichmsg){

clearTimeout(rotatemsgtimer)

if (ie4||ns6)

tickerexpand_item.className=""

currentmessage=whichmsg

rotatecontent()

}

 

function initialize_ticker(){

if (ns4) document.tickernsmain.visibility="show"

tickerobj=ie4? tickerlist : ns6? document.getElementById("tickerlist") : ns4? document.tickernsmain : ""

tickerexpandobj=ie4? tickerexpand : ns6? document.getElementById("tickerexpand") : ns4? document.expandlayer : ""

expandbuttonobj=ie4? expandbutton : ns6? document.getElementById("expandbutton") : ""

for (i=0;i<tickercontents.length;i++){ //get total scroller contents

tempstringcontainer=tickercontents[i].replace(/\<[^\>]+\>/g, ''); //remove HTML tags

tickercontentstotal+='<div id="expand'+i+'">- <a href="javascript:jumptomsg('+i+')">'+tempstringcontainer.substring(0, charslimit)+'...</a></div>'

}

if (ie4||ns6){

tickerexpandobj.innerHTML=tickercontentstotal

expandbuttonobj.innerHTML=expandtext

document.onclick=function(){

tickerexpandobj.style.visibility="hidden"

}

}

else if (ns4){

tickerexpandobj.document.write(tickercontentstotal)

tickerexpandobj.document.close()

tickerexpandobj.clip.width=parseInt(tickerwidth)*0.9

tickerobj.document.expandbuttonNS4.document.write(expandtext)

tickerobj.document.expandbuttonNS4.document.close()

tickerexpandobj.captureEvents(Event.CLICK)

tickerexpandobj.onclick=function(){

tickerexpandobj.visibility="hide"

}

}

rotatecontent()

}

 

if (ie4||ns6) //OUT HTML FOR TICKER AREA for IE/NS6

document.write('<table id="tickerarea" border="0" style="width:'+tickerwidth+';" bgcolor="'+tickerbgcolor+'" cellspacing="0" cellpadding="0"><tr><td id="tickerlist" width="100%" height="'+tickerheight+'" style="padding-left:3px" valign="top"></td></tr><tr><td width="90%"><div id="expandbutton" style="position:relative"></div></td></tr></table>')

 

window.onload=initialize_ticker

</script>

 

<ilayer id="tickernsmain" width=&{tickerwidth}; height=&{tickerheightNS4}; bgColor=&{tickerbgcolor}; visibility=hide><layer id="tickernssub" width=&{tickerwidth}; left=0 top=0></layer><layer id="expandbuttonNS4" left=0 top=&{tickerlistheightNS4};></layer></ilayer>

<layer id="expandlayer" bgColor=&{tickerbgcolor}; visibility=hide></layer>

 

Write a comment

Comments: 0