随笔分类 -  javascript

javascript脚本语言
摘要:一个网站的建设,经常会用到JavaScript,其中必须用到script标签来外调js文件,但是script标签属性用type还是language? type 和 language 属性都可用来指定 这两个标准提倡使用 type 属性。遗憾的是,这两个属性的值是不一样的。 其中属性type,值是MIME-type,意思是指示脚本的 MIME 类型,而language值是script,是不赞成使用。规定脚本语言。请使用 type 属性代替它。 您可能偶尔会看见language 的值为 VBScript(对 type 而言是 text/vbscript),表示包含的脚本代码是用 Microsoft 阅读全文
posted @ 2012-12-27 11:45 lines 阅读(3452) 评论(0) 推荐(1) 编辑
摘要:1. 去除页面的右键菜单$(document).ready(function(){ $(document).bind(“contextmenu”,function(e){returnfalse;});});当鼠标获得焦点、失去焦点的时候,input输入框文字处理: $(“input.text1″).val(“Enter your search text here”); textFill($(‘input.text1′));});function textFill(input){//input focus text functionvar originalvalue = input.val(.. 阅读全文
posted @ 2012-12-26 11:12 lines 阅读(341) 评论(0) 推荐(0) 编辑
摘要:这个图来自于《JavaScript语言精髓与编程实践》第三章P184页。此外,补充一下图中用到的概念:1、内置(Build-in)对象与原生(Naitve)对象的区别在于:前者总是在引擎初始化阶段就被创建好的对象,是后者的一个子集;而后者包括了一些在运行过程中动态创建的对象。2、引擎扩展对象是一个并不太大的集合,一般来说比较确定,它们也属于引擎的原生对象(但不属于ECMA规范的原生对象)。3、宿主对象不是引擎的原生对象,而是由宿主框架通过某种机制注册到JavaScript引擎中的对象。4、一些宿主会把自己提供的对象/构造器也称为“原生对象”,例如Internet Explorer 7就把它提供 阅读全文
posted @ 2012-12-26 11:03 lines 阅读(213) 评论(0) 推荐(0) 编辑
摘要:在使用过程中遇到了一些问题,通过修改iScroll框架得以解决,如下增加自定义滑动宽度iScroll框架默认滑动的宽度为当前获取对象的宽度,当在形如400px宽的对象里有4张图片,我们每次只希望滑动100px的宽度暨一张图片,做如下修改:1.在that.options里增加一个配置项getScrollW : “”,这里默认为空2.在refresh方法里找到that.wrapperW = that.wrapper.clientWidth;并修改为that.wrapperW = that.options.getScrollW ? that.options.getScrollW : that.wra 阅读全文
posted @ 2012-12-26 10:13 lines 阅读(1526) 评论(0) 推荐(0) 编辑
摘要:原理解析:第一步:使用dom创建无标题文档二 动态加载js文件的程序 loadjscssfile.js// JavaScript Documentfunction loadjscssfile(filename, filetype) {if (filetype == "js") {var fileref = document.createElement('script');fileref.setAttribute("type", "text/javascript");fileref.setAttribute(" 阅读全文
posted @ 2012-12-17 11:45 lines 阅读(376) 评论(0) 推荐(0) 编辑
摘要:常用:JS 获取浏览器窗口大小 1 // 获取窗口宽度 2 if (window.innerWidth) 3 winWidth = window.innerWidth; 4 else if ((document.body) && (document.body.clientWidth)) 5 winWidth = document.body.clientWidth; 6 // 获取窗口高度 7 if (window.innerHeight) 8 winHeight = window.innerHeight; 9 else if ((document.body) && 阅读全文
posted @ 2012-09-26 09:49 lines 阅读(1851) 评论(0) 推荐(0) 编辑
摘要:1 2 3 4 5 跟随鼠标移动实例 6 19 20 21 22 23 24 25 35 阅读全文
posted @ 2012-09-26 09:47 lines 阅读(271) 评论(0) 推荐(0) 编辑
摘要:1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="/Public/jquery/jquery-1.3.2.min.js" type="text/javascript"></script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <meta charset="utf-8"& 阅读全文
posted @ 2012-07-02 09:24 lines 阅读(1020) 评论(0) 推荐(0) 编辑
摘要:1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="gb2312"> 5 <title>HTML5--JS API-本地存储 Web留言板</title> 6 <style type="text/css"> 7 *{margin:0; padding:0;} 8 body,input{font-size:14px; line-height:24px; color:#333; font-family:Microsoft 阅读全文
posted @ 2012-06-28 12:46 lines 阅读(24359) 评论(3) 推荐(3) 编辑
摘要:1. document.form.item 问题 现有代码中存在许多 document.formName.item("itemName") 这样的语句,不能在Firefox下运行 解决方法: 统一使用 document.formName.elements["elementName"]2. 集合类对象问题 问题: IE下,可以使用()或[]获取集合类对象;Firefox下,只能使用[]获取集合类对象 解决方法: 改用[ ]作为下标运算。如:document.forms("formName") 改为 document.forms[&quo 阅读全文
posted @ 2012-06-04 15:55 lines 阅读(7062) 评论(0) 推荐(0) 编辑
摘要:常用:JS 获取浏览器窗口大小// 获取窗口宽度if (window.innerWidth)winWidth = window.innerWidth;else if ((document.body) && (document.body.clientWidth))winWidth = document.body.clientWidth;// 获取窗口高度if (window.innerHeight)winHeight = window.innerHeight;else if ((document.body) && (document.body.clientHeig 阅读全文
posted @ 2012-05-16 12:56 lines 阅读(331) 评论(0) 推荐(0) 编辑
摘要:1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu=return(false)><td>no</table> 可用于Table2. <body onselectstart="return false"> 取消选取、防止复制3. onpaste="return false" 不准粘贴4. oncopy="return false;" oncut=&q 阅读全文
posted @ 2012-04-23 14:37 lines 阅读(913) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文
posted @ 2012-04-20 18:22 lines 阅读(477) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文
posted @ 2012-04-20 17:46 lines 阅读(1857) 评论(1) 推荐(1) 编辑
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文
posted @ 2012-04-20 17:42 lines 阅读(966) 评论(0) 推荐(1) 编辑
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文
posted @ 2012-04-20 17:36 lines 阅读(1410) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文
posted @ 2012-04-20 13:30 lines 阅读(289) 评论(0) 推荐(0) 编辑
摘要:clientX 设置或获取鼠标指针位置相对于窗口客户区域的 x 坐标,其中客户区域不包括窗口自身的控件和滚动条。clientY 设置或获取鼠标指针位置相对于窗口客户区域的 y 坐标,其中客户区域不包括窗口自身的控件和滚动条。offsetX 设置或获取鼠标指针位置相对于触发事件的对象的 x 坐标。offsetY 设置或获取鼠标指针位置相对于触发事件的对象的 y 坐标。screenX 设置或获取获取鼠标指针位置相对于用户屏幕的 x 坐标。screenY 设置或获取鼠标指针位置相对于用户屏幕的 y 坐标。x 设置或获取鼠标指针位置相对于父文档的 x 像素坐标。y 设置或获取鼠标指针位置相对于父文档的 阅读全文
posted @ 2012-04-19 13:12 lines 阅读(22263) 评论(1) 推荐(0) 编辑
摘要:1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; c 阅读全文
posted @ 2012-04-01 12:40 lines 阅读(580) 评论(0) 推荐(0) 编辑
摘要:1 <!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; c 阅读全文
posted @ 2012-03-31 12:50 lines 阅读(685) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示