操作网页中的部分 - 创建,展开

时间:2011-12-18 01:40:20

标签: javascript html user-interface gmail

我有3个问题:

如何在网页中创建不同的部分 - 例如Gmail?

在设计HTML / Javascript页面时,如果您检查Gmail,将鼠标指向收件箱,展开该部分,然后将鼠标置于右侧,则将其返回到相同的位置 - 如何操作?他们使用了什么技术?

滚动条的问题相同 - 如何将普通滚动条的样式更改为我想要的其他样式?

1 个答案:

答案 0 :(得分:0)

首先,您可以将组划分为div,从而命名。但Javascript有一个相当简单的代码,这是我使用的整个代码

<p align="center" class="style1"><script language="JavaScript1.2">

var tickercontents=new Array()
tickercontents[0]='<strong>(text here)</strong></a>'
tickercontents[1]='<strong>(text here)</strong><a>'
tickercontents[2]='<strong>(text here)</strong><a>'


//configure the below 2 variables to set the width/background color of the ticker
var tickerwidth='760px'
var tickerbgcolor='#CC66FF'

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

////Do not edit past this line////////////////

var ie4=document.all
var ns6=document.getElementById
var ns4=document.layers

var currentmessage=0
var tickercontentstotal=''

function changetickercontent(){
if (ns4){
tickerobj.document.tickernssub.document.write('<b><a href="#" onClick="return      expandlist(event)">Expand</a></b> | '+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="expandhighlight"
}

currentmessage=(currentmessage==tickercontents.length-1)? 0 : currentmessage+1
setTimeout("changetickercontent()",tickdelay)
}

function start_ticking(){
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 : ""

for (i=0;i<tickercontents.length;i++) //get total scroller contents
tickercontentstotal+='<div id="expand'+i+'">- '+tickercontents[i]+'</div>'
if (ie4||ns6)
tickerexpandobj.innerHTML=tickercontentstotal
else{
tickerexpandobj.document.write(tickercontentstotal)
tickerexpandobj.document.close()
}
changetickercontent()
}

function expandlist(e){
if (ie4||ns6){
tickerexpand_parent=ie4? tickerexpand.parentElement :         document.getElementById("tickerexpand").parentNode
tickerexpand_parent.style.display=(tickerexpand_parent.style.display=="none")? "" :     "none"
}
else{
document.expandlayer.left=e.pageX-e.layerX
document.expandlayer.top= e.pageY-e.layerY+20
document.expandlayer.visibility=(document.expandlayer.visibility=="hide")? "show" :     "hide"
return false
}
}

if (ie4||ns6)
document.write('<table border="0" style="width:'+tickerwidth+';border:1px solid     black;text-indent:2px" bgcolor="'+tickerbgcolor+'" cellspacing="0" cellpadding="0"><tr><td     width="90%" id="tickerlist" bgcolor="'+tickerbgcolor+'"></td><td width="10%"     bgcolor="'+tickerbgcolor+'"><div id="listbutton" onClick="expandlist()">Expand</div></td>    </tr><tr style="display:none"><td id="tickerexpand" width="90%" bgcolor="'+tickerbgcolor+'">     </td><td width="10%"></td></tr></table>')

window.onload=start_ticking
</script>