当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 网页制作中常用的Javascript代码

Javascript
javascript的事件描述
用javascript动态注释掉HTML代码
对联广告
[原创]菜单制作学习一个小东西
JavaScript中的私有成员
基于Web标准的UI组件 — 树状菜单(2)
JavaScript静态的动态
JavaScript Base64编码和解码,实现URL参数传递。
跨浏览器的设置innerHTML方法
多个iframe自动调整大小的问题
判断checkbox选择的个数 多浏览器
发现的以前不知道的函数
Js+XML 操作
Javascript里使用Dom操作Xml
JS+CSS模拟IP输入框
prototype1.5 初体验
prototype 源码中文说明之 prototype.js
prototype1.4中文手册
获取页面高度,窗口高度,滚动条高度等参数值getPageSize,getPageScroll
js实现ASP分页函数 HTML分页函数

网页制作中常用的Javascript代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 280 ::
收藏到网摘: n/a

本文介绍了一些网页制作中常用的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.ruanchen.com/">

  关闭输入法

  以下是引用片段:

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

  自动全选

  以下是引用片段:

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