JavaScript怎样写谷歌首页的“更多”
http://www.google.cn/
中的那个更多用JavaScript怎么实现?不要用jQ.
HTML code:
<script type="text/javascript">
function showMenu(e) {
document.getElementById("subMenu").style.display = "block";
//防止事件冒泡
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble = true;
return false;
}
document.onclick = function() {
if (document.getElementById("subMenu").style.display = "block") {
document.getElementById("subMenu").style.display = "none";
}
}
</script>
<a href="javascript:void(0);" onclick="showMenu(event)">更多</a>
<div id="subMenu" style="position: absolute; display: none; border: 1px solid #ccc;">
<p>
<a href="#" onclick="alert(1)">menu1</a></p>
<p>
menu2</p>
</div>
非常感谢,能说说//防止冒泡事件的作用吗?
实在是太强了,谢谢!
不放置冒泡的话。点击更多,先展开,又因为document.onclick而关闭了。
1楼强啊。。真快
顶
相关问答:
function check(){
if(document.form1.LXRMC.value=="" || document.form1.DZ.value=="" || document.form1.LXRMC.value==""
|| document.form1. ......
我模仿“实现网络蚂蚁、JETCAR等软件之IE右键菜单的“用xxxxxx下载”例子,”在ie右击菜单弹出一个应用程序,在我的机子上运行能实现效果,但是我把运行好的程序打包到另一机子上(“HKEY_CURRENT_USER\Software\Mic ......
.cs文件里代码:
string ss="12345";
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "", " <scrip ......
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(),this.ClientID, " <script language=\"javascript\" type=\"text/javascript\"> if(confirm('需要直接 ......