代码如下: function getByClass(classname){ var nodes = document.getElementsByTagName(*), ret=[]; for(var i=0;i<nodes.length;i++){ if(hasClass(nodes[i],classname)) ret.push(nodes[i]); } return ret; } function hasClass(node,className){ var names = node.className.split(/\s+/); for(var i=0;i<names.length;i++){ if(names[i]==className) return true; }return false; }
语句1. window.parent.frames[1].location.reload(); 语句2. window.parent.frames.bottom.location.reload(); 语句3. window.parent.frames["bottom"].location.reload(); 语句4. window.parent.frames.item(1).location.reload(); 语句5. window.parent.frames.item('bottom').location.reload(); 语句6. window.parent.bottom.location.reload(); 语句7. window.parent['bottom'].location.reload();
最近准备学学Javascript和Raphaël,实现一个可拖动的矩形,另外矩形上还得显示标签。查了一下网上这个东西还比较冷门。Javascript才学没几天,代码估计写的很烂。 代码如下: Raphaël - Connectivities function Entity(r, l, t, w, h){ this.Label = r.text(l + w/2, t + h/2, "Hello World!"); this.Rectangle = r.rect(l, t, w, h, 10).attr({fill:"brown", stroke:"#666", title:"A Rectangle"}).drag(move, Dr...
代码如下: JS+CSS制作的DIV层最小化和随意拖拽排序功能 body { margin:10px; } #dragHelper { position:absolute;/*重要*/ border:2px dashed #000000; background-color:#FFFFFF; filter: alpha(opacity=30); } .normal { position:absolute;/*重要*/ width:300px; #height:10px; border:1px solid #666666; background-color:#FFFFFF; } .over { position:absolute;/*重要*/ width:300px; #height:10px; border:1px solid #66...
在处理网页图片时,特别是一些图片列表的应用里面,很难保证图片统一大小,直接设置图片大小又会导致图片拉伸,造成图片模糊,本文介绍的代码可以在图片加载完成后自动按比例调整图片大小。 Javascript: 代码如下: < script language="javascript" type="text/javascript"> < !-- // 说明:用 JavaScript 实现网页图片等比例缩放 // 整理:http://www.CodeBit.cn function DrawImage(ImgD,FitWidth,FitHeight) { var image=new Image(...
HTML代码 代码如下: RepeatColumns="4" RepeatDirection="horizontal"> </asp:ListItem> </asp:ListItem> </asp:ListItem> </asp:ListItem> <input id="Button1" type="button" value="button" onclick="return RadioButtonList1Changed()" JS代码: 代码如下: function RadioButtonList1Changed() { var rbtn = document.getElementByIdx_x("rbtnCompany"); //得到所有radio var list= rbtn .getElementsByTagName_r("input")...
1.链接 代码如下: 'c_06c','onclick'=>'return art_del_confirm("/company/msglog/delete/id/'.$data->zml_id.'","你确定要删除这条消息吗?")'))?> 2.jq 代码如下: //单项删除确认框 function art_del_confirm(url,message){ message = message?message:'你确定要删除这条数据吗?'; art.dialog({ title: '确认删除', okValue:'确认', cancelValue:'取消', width: 230, height: 100, fixed: true, content: message, ok: func...
利用JS实现的根据经纬度计算地球上两点之间的距离 最近用到了根据经纬度计算地球表面两点间距离的公式,然后就用JS实现了一下。 计算地球表面两点间的距离大概有两种办法。 第一种是默认地球是一个光滑的球面,然后计算任意两点间的距离,这个距离叫做大圆距离(The Great Circle Distance)。 公式如下: 使用JS来实现为: 代码如下: var EARTH_RADIUS = 6378137.0; //单位M var PI = Math.PI; function getRad(d){ return d*PI/18...
自从Pinterest使用了一种新的方式布局取得成功之后,从此互联网出现了布局潮流,我们把他叫做瀑布流!!在互联网流行起来,从国外到国内普遍存在。国内现有美丽说,蘑菇街,花瓣等代表的网站。 瀑布流是流行一段时间了,现在网上出现了很多的插件。使用起来更是非常的方便。目前用的非常多,并且有是一个juqery的插件masonry,插件地址:http://masonry.desandro.com/ 先使用css把一个网页按照从上到下的方式布局好。 使用起来更是...
做项目时,客户提出这样一个要求,在列表中的文本框里输入数据时,要能够通过上下左右键来切换光标,按回车键就把光标移到下一个文本框。这样就省得一直去用鼠标了,操作起来更方便。 不废话,上代码。 代码如下: EnableModelValidation="True" Width="100%" PagerStyle-HorizontalAlign="Center"> "> 57) event.returnValue = false;" MaxLength="5"> 代码如下: jquery代码 $(function() { $("input").eq...
在做表单页面的时候,想判断2个js对象,是不是所有完全相同。这里是stackoverflow上的解决办法,在这里记录一下。 代码如下: Object.prototype.equals = function(x) { var p; for(p in this) { if(typeof(x[p])==undefined) {return false;} } for(p in this) { if (this[p]) { switch(typeof(this[p])) { case object: if (!this[p].equals(x[p])) { return false; } break; case function: if (typeof(x[p])==undefined || (p ...
浏览网站时经常看到有的网站上,侧栏里的有些内容滚动到页面顶端以后就固定在那个位置,不再跟随滚动条而滚动。这种效果叫做“侧栏跟随滚动”。它对于那些不希望被滚动到页面之外的内容是非常有用的。 侧栏跟随滚动的实现方法有很多种,比较常见的有两种,这两种方法在NEOEASE写的一篇文章中介绍的很清楚,一种是借助jQuery来实现,这种方法对于那些平时不需要加载jQuery库的网站来说,显然是一种负担(jQuery现在是越做越大了……...
用JavaScript创建一个欢迎cookie 软件代码编辑器,我用的是editplus;当然还有浏览器。步骤 先在编辑器里写入代码:运行代码,并写入自己的名字:得到欢迎cookie.
DIV+CSS+JS实现不间断横向滚动代码 代码如下: 横向不间断滚动DIV CSS代码-DIVCSS5 .scroll_div {width:600px; height:49px;margin:0 auto; overflow: hidden; white-space: nowrap; background:#ffffff;} .scroll_div img {width:120px;height:49px;border: 0;margin: auto 8px; } #scroll_begin, #scroll_end, #scroll_begin ul, #scroll_end ul, #scroll_begin ul li, #scroll_end ul li{display:inline;}/* 设置ul和li横...
代码如下: 用户注册 function MyForm(){ msg.innerHTML="debug::in function"; var username = document.form1.username.value; var msg = document.getElementById("msg"); if(username.length==0){ msg.innerHTML="[ 提示:用户名不能为空! ]"; document.form1.username.focus(); return false; } var pass = document.form1.password.value; if(pass.length==0){ msg.innerHTML="[ 提示:密码不能为空! ]"; document.form...