网页制作中常用的Javascript代码


本文介绍了一些网页制作中常用的Javascript代码,应该是比较常用的了,值得大家收藏。

  事件源对象

  以下是引用片段:

  event.srcElement.tagName

  event.srcElement.type

  捕获释放

  以下是引用片段:

  event.srcElement.setCapture();

  event.srcElement.releaseCapture();

  事件按键

  以下是引用片段:

  event.keyCode

  event.shiftKey

  event.altKey

  event.ctrlKey

  事件返回值

  以下是引用片段:

  event.returnValue

  鼠标位置

  以下是引用片段:

  event.x

  event.y

  窗体活动元素

  以下是引用片段:

  document.activeElement

  绑定事件

  以下是引用片段:

  document.captureEvents(Event.KEYDOWN);

  访问窗体元素

  以下是引用片段:

  document.all("txt").focus();

  document.all("txt").select();

  窗体命令

  以下是引用片段:

  document.execCommand

  窗体COOKIE

  以下是引用片段:

  document.cookie

  菜单事件

  以下是引用片段:

  document.oncontextmenu

  创建元素

  以下是引用片段:

  document.createElement("SPAN");

  根据鼠标获得元素:

  以下是引用片段:

  document.elementFromPoint(event.x,event.y).tagName=="TD

  document.elementFromPoint(event.x,event.y).appendChild(ms)

  窗体图片

  以下是引用片段:

  document.images[索引]

  

  窗体事件绑定

  以下是引用片段:

  document.onmousedown=scrollwindow;

  元素

  以下是引用片段:

  document.窗体.elements[索引]

  对象绑定事件

  以下是引用片段:

  document.all.xxx.detachEvent('onclick',a);

  插件数目

  以下是引用片段:

  navigator.plugins

  取变量类型

  以下是引用片段:

  typeof(js_libpath) == "undefined"

  

  下拉框

  以下是引用片段:

  下拉框.options[索引]

  下拉框.options.length

  查找对象

  以下是引用片段:

  document.getElementsByName("r1");

  document.getElementById(id);

  定时

  以下是引用片段:

  timer=setInterval('scrollwindow()',delay);

  clearInterval(timer);

  上一网页源

  以下是引用片段:

  asp:

  request.servervariables("HTTP_REFERER")

  javascript:

  document.referrer

  释放内存

  以下是引用片段:

  CollectGarbage();

  禁止右键

  以下是引用片段:

  document.oncontextmenu = function() { return false;}

  禁止保存

  以下是引用片段:

  <noscript><iframe src="*.htm"></iframe></noscript>

  禁止选取

  以下是引用片段:

  <body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()>

  禁止粘贴

  以下是引用片段:

  <input type=text onpaste="return false">

  地址栏图标

  以下是引用片段:

  <link rel="Shortcut Icon" href="favicon.ico">

  favicon.ico 名字最好不变16*16的16色,放虚拟目录根目录下

  收藏栏图标

  以下是引用片段:

  <link rel="Bookmark" href="favicon.ico">

  查看源码

  

  以下是引用片段:

  <input type=button value=查看网页源代码 onclick="window.location = 'view-source:' 'http://www.phpstudy.net/'">

  关闭输入法

  以下是引用片段:

  <input style="ime-mode:disabled">

  自动全选

  以下是引用片段:

  <input type=text name=text1 value="123" onfocus="this.select()">


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3