php插入mysql数据避免重复插入
作者:admin 日期:2012-04-24
Jquery实现链接批量设置新窗口打开
作者:admin 日期:2012-04-30
首先调用jquery类文件:
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
非站内链接新窗口打开:
- <script type="text/javascript">
- jQuery(function($){
- $("a[href*='://']:not(a[href^='http://www.jlist.cn'],a[href^='javascript:'])").attr("target", "_blank");})
- </script>
实际上是jquery方法属性的基本应用!
演示地址:https://blog.guanjianci.net/codetest/jquery/openwithblank.html
Javascript滚动条事件onscroll测试
作者:admin 日期:2012-04-30
从结果可以看出只要页面滚动onscroll就不停触发。
- <div id='TzgTestDiv'></div>
- <script language="javascript" type="text/javascript">
- var i=1;
- function showcroll(){
- i=i + 1;
- document.getElementById("TzgTestDiv").innerHTML="滚动了" + i + "次";
- }
- window.onscroll = showcroll;
- </script>
原创代码,转载请注明出处,谢谢!
Javascript返回页面顶部的滚动特效
作者:admin 日期:2012-04-29
和前面的一篇文章作用一样,这个代码写得不错!
- var goto_top_type = -1;
- var goto_top_itv = 0;
- function goto_top_timer()
- {
- var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
- var moveby = 15;
- y -= Math.ceil(y * moveby / 100);
- if (y < 0) {
- y = 0;
- }
- if (goto_top_type == 1) {
- document.documentElement.scrollTop = y;
- }
- else {
- document.body.scrollTop = y;
- }
- if (y == 0) {
- clearInterval(goto_top_itv);
- goto_top_itv = 0;
- }
- }
- function goto_top()
- {
- if (goto_top_itv == 0) {
- if (document.documentElement && document.documentElement.scrollTop) {
- goto_top_type = 1;
- }
- else if (document.body && document.body.scrollTop) {
- goto_top_type = 2;
- }
- else {
- goto_top_type = 0;
- }
- if (goto_top_type > 0) {
- goto_top_itv = setInterval('goto_top_timer()', 50);
- }
- }
- }
有时间研究下这个网站的效果:http://webdesignerwall.com/
Javascript实现网页平滑滚动回到顶部
作者:admin 日期:2012-04-29
很多网页在下方都会放置一个“返回顶部”按钮,尤其是页面底部没有导航的网页,这样可以帮助访客重新找到导航或者重温一遍广告(想得真美)。随着近几年来 JavaScript 的应用日渐广泛,滑动效果无处不在,于是我也跟跟风,将返回顶部功能做成了滑动效果。后来为了更贴合物理特征, 改造做成了减速的滑动效果。
首先说一下原理吧,我们会获取滚动条到页面顶部的距离,然后上移一定的距离;再获取滚动条到页面顶部的距离,上移一定的距离(比上一次小一点);以此类推 ...
- <script type="text/javascript">
- /**
- * 回到页面顶部
- * @param acceleration 加速度
- * @param time 时间间隔 (毫秒)
- **/
- function goTop(acceleration, time) {
- acceleration = acceleration || 0.1;
- time = time || 16;
- var x1 = 0;
- var y1 = 0;
- var x2 = 0;
- var y2 = 0;
- var x3 = 0;
- var y3 = 0;
- if (document.documentElement) {
- x1 = document.documentElement.scrollLeft || 0;
- y1 = document.documentElement.scrollTop || 0;
- }
- if (document.body) {
- x2 = document.body.scrollLeft || 0;
- y2 = document.body.scrollTop || 0;
- }
- var x3 = window.scrollX || 0;
- var y3 = window.scrollY || 0;
- // 滚动条到页面顶部的水平距离
- var x = Math.max(x1, Math.max(x2, x3));
- // 滚动条到页面顶部的垂直距离
- var y = Math.max(y1, Math.max(y2, y3));
- // 滚动距离 = 目前距离 / 速度, 因为距离原来越小, 速度是大于 1 的数, 所以滚动距离会越来越小
- var speed = 1 + acceleration;
- window.scrollTo(Math.floor(x / speed), Math.floor(y / speed));
- // 如果距离不为零, 继续调用迭代本函数
- if(x > 0 || y > 0) {
- var invokeFunction = "goTop(" + acceleration + ", " + time + ")";
- window.setTimeout(invokeFunction, time);
- }
- }
- </script>
调用方法:
- <a href="#" onclick="goTop();return false;">TOP</a>
Javascript实现透明度渐变效果
作者:admin 日期:2012-04-29
vb6 winhttp 用法操作
作者:admin 日期:2012-04-29
Dim WithEvents oreq As WinHttpRequest
Private Sub Command1_Click()
' Create a WinHttpRequest object.
Set oreq = New WinHttpRequest
' Open an HTTP connection.
oreq.Open "GET", "http://ServerName/ASPPage.asp", True
' Set the receive timeout to 3 seconds.
oreq.SetTimeouts 60000, 60000, 60000, 3000
' Send an HTTP request to the server.
oreq.Send
End Sub
Private Sub oreq_OnError(ByVal ErrorNumber As Long, ByVal ErrorDescription As String)
' Display the description of the error.
MsgBox ErrorDescription
End Sub
Private Sub oreq_OnResponseFinished()
' Display the response from the server.
MsgBox oreq.ResponseText
End Sub
ServerXMLHTTP及XMLHTTP的差别
作者:admin 日期:2012-04-29
一般在 client side 的 ajax 会用到这个 component (for IE) Microsoft.XMLHTTP, 若是在 server 端的 asp 程序代码使用这组 code, 来访问其他站台的内容时, 可以利用程序代码如下:
- Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
- xmlhttp.Open "GET", "http://www.baidu.com/", False
- xmlhttp.Send
- Response.Write xmlhttp.ResponseTEXT
- Set xmlhttp = Nothing
不过这个有一些些问题, 因为 XMLHTTP 本身的工作行为是绑在 IE API 上, 当然是有好有坏, 根据微软的文件, 这组组件是适合用在客户端而非 server 端, 在使用上会有一些稳定及效能的问题, 不过更有趣的还有一个地方, 就是他会增进效能而在本机的文件系统上存入访问的内容, 路径如下:
C:\WINDOWS\Temp\Temporary Internet Files\Content.IE5
也就是说, 会占用掉部分的空间, 但实际观察又不全然是这种 cache 的状况, 因为相同的网页, 被重复 reload 时, 该 cache 用的目录居然也会成长, 也就是说, 原来设计为 cache 的功能, 也有可能用不到, 但用不到还没关系, 会一直占用空间成长(无上限), 这个就比较麻烦了.
之前笔者在追踪一个案例(c:碟占用空间持续成长的状况), 原来就是这个组件的毛病, 实际再测, 若是访问的网页是非 xml 时, 似乎就没有这种状况, 不过大多数的应用环境, 数据都会选 xml 的方式来传送, 所以仍会有这个问题存在.
为了解决这个问题, 还有另一组组件可供使用, MSXML2.ServerXMLHTTP, 这组组件提供了更稳定的方式来执行前述功能, 而且几乎完全兼容语法, 并提供了更多的功能, 也不会产生大量的cache 临时文件, 我们来看看微软官网上对此二者的比较:
http://support.microsoft.com/kb/290761
主要差异点如下:
XMLHTTP is designed for client applications and relies on URLMon, which is built upon Microsoft Win32 Internet (WinInet). ServerXMLHTTP is designed for server applications and relies on a new HTTP client stack, WinHTTP. ServerXMLHTTP offers reliability and security and is server-safe. For more information, see the MSXML Software Development Kit (SDK) documentation.
如此一来便可以很清楚地了解在 asp 程序内, 使用 XMLHTTP 及 ServerXMLHTTP 的差异了, 将上面的程序代码改为:
- Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
- xmlhttp.Open "GET", "http://diary.tw/tim/", False
- xmlhttp.Send
- Response.Write xmlhttp.ResponseTEXT
- Set xmlhttp = Nothing
Asp正则验证是否有效的URL
作者:admin 日期:2012-04-28
这段代码可以用来判断用户输入的网址格式是否正确?
- Function valid(ByVal str)
- Dim temp,reg
- Set reg = new regexp
- reg.ignorecase=true
- reg.global=true
- temp = "^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$"
- reg.pattern = temp
- valid = reg.test(Trim(str))
- Set reg = Nothing
- End Function
调用方法:
- if valid(url)=false then
- response.Write("不是完整有效的URL!")
- response.End()
- end if
原创代码,转载请注明出处,谢谢!
PHP中逗号和点号的区别
作者:admin 日期:2012-04-27
jquery页面中固定显示div层
作者:admin 日期:2012-04-27
这个是别人写的代码,自己实际用的时候对代码做了改动,主要需要新增一些功能!
- /*任意位置浮动固定层*/
- /*没剑(http://regedit.cnblogs.com) 2009-03-04*/
- /*说明:可以让指定的层浮动到网页上的任何位置,当滚动条滚动时它会保持在当前位置不变,不会产生闪动*/
- /*2009-06-10修改:重新修改插件实现固定浮动层的方式,使用一个大固定层来定位
- /*2009-07-16修改:修正IE6下无法固定在top上的问题
- /*09-11-5修改:当自定义层的绝对位置时,加上top为空值时的判断
- 这次的方法偷自天涯新版页
- 经多次测试,基本上没bug~
- 有问题的朋友欢迎到偶的博客http://regedit.cnblogs.com上提出
- */
- /*调用:
- 1 无参数调用:默认浮动在右下角
- $("#id").floatdiv();
- 2 内置固定位置浮动
- //右下角
- $("#id").floatdiv("rightbottom");
- //左下角
- $("#id").floatdiv("leftbottom");
- //右下角
- $("#id").floatdiv("rightbottom");
- //左上角
- $("#id").floatdiv("lefttop");
- //右上角
- $("#id").floatdiv("righttop");
- //居中
- $("#id").floatdiv("middle");
- 另外新添加了四个新的固定位置方法
- middletop(居中置顶)、middlebottom(居中置低)、leftmiddle、rightmiddle
- 3 自定义位置浮动
- $("#id").floatdiv({left:"10px",top:"10px"});
- 以上参数,设置浮动层在left 10个像素,top 10个像素的位置
- */
- jQuery.fn.floatdiv=function(location){
- //判断浏览器版本
- var isIE6=false;
- var Sys = {};
- var ua = navigator.userAgent.toLowerCase();
- var s;
- (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 0;
- if(Sys.ie && Sys.ie=="6.0"){
- isIE6=true;
- }
- var windowWidth,windowHeight;//窗口的高和宽
- //取得窗口的高和宽
- if (self.innerHeight) {
- windowWidth=self.innerWidth;
- windowHeight=self.innerHeight;
- }else if (document.documentElement&&document.documentElement.clientHeight) {
- windowWidth=document.documentElement.clientWidth;
- windowHeight=document.documentElement.clientHeight;
- } else if (document.body) {
- windowWidth=document.body.clientWidth;
- windowHeight=document.body.clientHeight;
- }
- return this.each(function(){
- var loc;//层的绝对定位位置
- var wrap=$("<div></div>");
- var top=-1;
- if(location==undefined || location.constructor == String){
- switch(location){
- case("rightbottom")://右下角
- loc={right:"0px",bottom:"0px"};
- break;
- case("leftbottom")://左下角
- loc={left:"0px",bottom:"0px"};
- break;
- case("lefttop")://左上角
- loc={left:"0px",top:"0px"};
- top=0;
- break;
- case("righttop")://右上角
- loc={right:"0px",top:"0px"};
- top=0;
- break;
- case("middletop")://居中置顶
- loc={left:windowWidth/2-$(this).width()/2+"px",top:"0px"};
- top=0;
- break;
- case("middlebottom")://居中置低
- loc={left:windowWidth/2-$(this).width()/2+"px",bottom:"0px"};
- break;
- case("leftmiddle")://左边居中
- loc={left:"0px",top:windowHeight/2-$(this).height()/2+"px"};
- top=windowHeight/2-$(this).height()/2;
- break;
- case("rightmiddle")://右边居中
- loc={right:"0px",top:windowHeight/2-$(this).height()/2+"px"};
- top=windowHeight/2-$(this).height()/2;
- break;
- case("middle")://居中
- var l=0;//居左
- var t=0;//居上
- l=windowWidth/2-$(this).width()/2;
- t=windowHeight/2-$(this).height()/2;
- top=t;
- loc={left:l+"px",top:t+"px"};
- break;
- default://默认为右下角
- location="rightbottom";
- loc={right:"0px",bottom:"0px"};
- break;
- }
- }else{
- loc=location;
- alert(loc.bottom);
- var str=loc.top;
- //09-11-5修改:加上top为空值时的判断
- if (typeof(str)!= 'undefined'){
- str=str.replace("px","");
- top=str;
- }
- }
- /*fied ie6 css hack*/
- if(isIE6){
- if (top>=0)
- {
- wrap=$("<div style=\"top:expression(documentElement.scrollTop+"+top+");\"></div>");
- }else{
- wrap=$("<div style=\"top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight);\"></div>");
- }
- }
- $("body").append(wrap);
- wrap.css(loc).css({position:"fixed",
- z_index:"999"});
- if (isIE6)
- {
- wrap.css("position","absolute");
- //没有加这个的话,ie6使用表达式时就会发现跳动现象
- //至于为什么要加这个,还有为什么要加nothing.txt这个,偶也不知道,希望知道的同学可以告诉我
- $("body").css("background-attachment","fixed").css("background-image","url(n1othing.txt)");
- }
- //将要固定的层添加到固定层里
- $(this).appendTo(wrap);
- });
- };
下载地址:http://files.cnblogs.com/regedit/jquery.floatdiv.rar
原文网址:http://www.cnblogs.com/regedit/archive/2008/03/11/1100170.html
Asp利用MID分割字符示例
作者:admin 日期:2012-04-27
广告位