随笔分类 -  JavaScript

摘要:function closeCurrWindow(){ var browserName=navigator.appName; alert(browserName); if (browserName=="Netscape") { window.open('','_self',''); window.close(); } else if (browserName=="Microsoft Internet Explorer") { window.opener = "whoCares"; ... 阅读全文
posted @ 2013-05-18 14:10 摩根船长 阅读(405) 评论(0) 推荐(0) 编辑
摘要:有时我们看到一些大型网站,页面如果有很多图片的时候,当你滚动到相应的行时,当前行的图片才即时加载的,这样子的话页面在打开只加可视区域的图片,而其它隐藏的图片则不加载,一定程序上加快了页面加载的速度,对于比较长的页面来说,这个方案是比较好的。这里推荐使用jquery图片延迟加载插件jquery.lazyload实现图片延迟加载提高网站打开速度下载地址:http://www.appelsiini.net/download/jquery.lazyload.js修正版:jquery.lazyload修正版.rar(修正版说明)一、快速使用篇1.导入JS插件<script src="js 阅读全文
posted @ 2012-12-27 17:57 摩根船长 阅读(14794) 评论(0) 推荐(1) 编辑
摘要://selector:可以为dom对象,也可以为dom对象的id值//etype:监听的事件类型:up,down,left,right//endFun:事件完毕后的回调方法var zyEvent = function(selector,etype,endFun){<script>function log(s){ document.getElementById("contid").innerHTML = s;}var eva = new zyEvent(document,'up',function(){log('向上滑动')});v 阅读全文
posted @ 2012-12-15 09:45 摩根船长 阅读(9555) 评论(0) 推荐(0) 编辑
摘要:location.hash 设置或获取 href 属性中在井号“#”后面的分段。 location.host 设置或获取 location 或 URL 的 hostname 和 port 号码。 location.hostname 设置或获取 location 或 URL 的主机名称部分。 location.href 设置或获取整个 URL 为字符串。 location.pathname 设置或获取对象指定的文件名或路径。 location.port 设置或获取与 URL 关联的端口号码。 location.protocol 设置或获取 URL 的协议部分。 location.search 设 阅读全文
posted @ 2012-09-28 16:37 摩根船长 阅读(503) 评论(0) 推荐(0) 编辑
摘要:JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串。var a = "hello";var b = ",world";var c = a.concat(b);alert(c); //c = "hello,world"indexOf返回字符串中一个子串第一处出现的索引(从左到右搜索)。如果没有匹配项,返回 -1 。var index1 = a.indexOf("l"); //index1 = 2var index2 = a.indexOf("l",3); //index2 阅读全文
posted @ 2012-09-24 11:16 摩根船长 阅读(308) 评论(0) 推荐(0) 编辑
摘要:"window.location.href"、"location.href"是本页面跳转"parent.location.href"是上一层页面跳转"top.location.href"是最外层的页面跳转举例说明:如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写 "window.location.href"、"location.href":D页面跳转"parent.location.href" 阅读全文
posted @ 2012-09-10 21:43 摩根船长 阅读(3297) 评论(0) 推荐(0) 编辑
摘要:一、数组转字符串(将数组元素用某个字符连接成字符串)var a, b;a = new Array(0,1,2,3,4);b = a.join("-");二、字符串转数组(将字符串按某个字符切割成若干个字符串,并以数组形式返回)var s = "abc,abcd,aaa";ss = s.split(",");// 在每个逗号(,)处进行分解。 阅读全文
posted @ 2012-09-10 11:23 摩根船长 阅读(14890) 评论(0) 推荐(0) 编辑
摘要:<script type="text/javascript"> $(document).ready(function () { var usAgent = navigator.userAgent.toLowerCase(); if (usAgent.indexOf("android") >= 0 || usAgent.indexOf("iphone") >= 0 || usAgent.indexOf("ipod") >= 0 || usAgent.indexOf("ipad& 阅读全文
posted @ 2012-08-21 14:07 摩根船长 阅读(279) 评论(0) 推荐(0) 编辑