预览模式: 普通 | 列表

php插入mysql数据避免重复插入

Jquery实现链接批量设置新窗口打开

首先调用jquery类文件:

XML/HTML代码
  1. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>  

非站内链接新窗口打开:

JavaScript代码
  1. <script type="text/javascript">   
  2. jQuery(function($){   
  3. $("a[href*='://']:not(a[href^='http://www.jlist.cn'],a[href^='javascript:'])").attr("target""_blank");})   
  4. </script>  

实际上是jquery方法属性的基本应用!

演示地址:https://blog.guanjianci.net/codetest/jquery/openwithblank.html

查看更多...

Tags: jquery

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2434

Javascript滚动条事件onscroll测试

从结果可以看出只要页面滚动onscroll就不停触发。

XML/HTML代码
  1. <div id='TzgTestDiv'></div>  
  2. <script language="javascript" type="text/javascript">  
  3. var i=1;   
  4. function showcroll(){   
  5. i=i + 1;   
  6. document.getElementById("TzgTestDiv").innerHTML="滚动了" + i + "次";   
  7. }   
  8. window.onscroll = showcroll;   
  9. </script>  

原创代码,转载请注明出处,谢谢!

Tags: javascript onscroll

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2939

Javascript返回页面顶部的滚动特效

和前面的一篇文章作用一样,这个代码写得不错!

JavaScript代码
  1. var goto_top_type = -1;  
  2. var goto_top_itv = 0;  
  3.   
  4. function goto_top_timer()  
  5. {  
  6. var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;  
  7. var moveby = 15;  
  8.   
  9. y -= Math.ceil(y * moveby / 100);  
  10. if (y < 0) {  
  11. y = 0;  
  12. }  
  13.   
  14. if (goto_top_type == 1) {  
  15. document.documentElement.scrollTop = y;  
  16. }  
  17. else {  
  18. document.body.scrollTop = y;  
  19. }  
  20.   
  21. if (y == 0) {  
  22. clearInterval(goto_top_itv);  
  23. goto_top_itv = 0;  
  24. }  
  25. }  
  26.   
  27. function goto_top()  
  28. {  
  29. if (goto_top_itv == 0) {  
  30. if (document.documentElement && document.documentElement.scrollTop) {  
  31. goto_top_type = 1;  
  32. }  
  33. else if (document.body && document.body.scrollTop) {  
  34. goto_top_type = 2;  
  35. }  
  36. else {  
  37. goto_top_type = 0;  
  38. }  
  39.   
  40. if (goto_top_type > 0) {  
  41. goto_top_itv = setInterval('goto_top_timer()', 50);  
  42. }  
  43. }  
  44. }  

有时间研究下这个网站的效果:http://webdesignerwall.com/

Tags: javascript

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2426

Javascript实现网页平滑滚动回到顶部

很多网页在下方都会放置一个“返回顶部”按钮,尤其是页面底部没有导航的网页,这样可以帮助访客重新找到导航或者重温一遍广告(想得真美)。随着近几年来 JavaScript 的应用日渐广泛,滑动效果无处不在,于是我也跟跟风,将返回顶部功能做成了滑动效果。后来为了更贴合物理特征, 改造做成了减速的滑动效果。

首先说一下原理吧,我们会获取滚动条到页面顶部的距离,然后上移一定的距离;再获取滚动条到页面顶部的距离,上移一定的距离(比上一次小一点);以此类推 ...

JavaScript代码
  1. <script type="text/javascript">  
  2. /** 
  3.  * 回到页面顶部 
  4.  * @param acceleration 加速度 
  5.  * @param time 时间间隔 (毫秒) 
  6.  **/  
  7. function goTop(acceleration, time) {  
  8.     acceleration = acceleration || 0.1;  
  9.     time = time || 16;  
  10.    
  11.     var x1 = 0;  
  12.     var y1 = 0;  
  13.     var x2 = 0;  
  14.     var y2 = 0;  
  15.     var x3 = 0;  
  16.     var y3 = 0;  
  17.    
  18.     if (document.documentElement) {  
  19.         x1 = document.documentElement.scrollLeft || 0;  
  20.         y1 = document.documentElement.scrollTop || 0;  
  21.     }  
  22.     if (document.body) {  
  23.         x2 = document.body.scrollLeft || 0;  
  24.         y2 = document.body.scrollTop || 0;  
  25.     }  
  26.     var x3 = window.scrollX || 0;  
  27.     var y3 = window.scrollY || 0;  
  28.    
  29.     // 滚动条到页面顶部的水平距离  
  30.     var x = Math.max(x1, Math.max(x2, x3));  
  31.     // 滚动条到页面顶部的垂直距离  
  32.     var y = Math.max(y1, Math.max(y2, y3));  
  33.    
  34.     // 滚动距离 = 目前距离 / 速度, 因为距离原来越小, 速度是大于 1 的数, 所以滚动距离会越来越小  
  35.     var speed = 1 + acceleration;  
  36.     window.scrollTo(Math.floor(x / speed), Math.floor(y / speed));  
  37.    
  38.     // 如果距离不为零, 继续调用迭代本函数  
  39.     if(x > 0 || y > 0) {  
  40.         var invokeFunction = "goTop(" + acceleration + ", " + time + ")";  
  41.         window.setTimeout(invokeFunction, time);  
  42.     }  
  43. }   
  44. </script>  

调用方法:

XML/HTML代码
  1. <a href="#" onclick="goTop();return false;">TOP</a>

Tags: javascript

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3139

Javascript实现透明度渐变效果 加密日志

该日志是加密日志,需要输入正确密码才可以查看!
分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2137

vb6 winhttp 用法操作

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

Tags: vb

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 4242

ServerXMLHTTP及XMLHTTP的差别

 一般在 client side 的 ajax 会用到这个 component (for IE) Microsoft.XMLHTTP, 若是在 server 端的 asp 程序代码使用这组 code, 来访问其他站台的内容时, 可以利用程序代码如下:

ASP/Visual Basic代码
  1. Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")  
  2. xmlhttp.Open "GET""http://www.baidu.com/"False  
  3. xmlhttp.Send  
  4. Response.Write xmlhttp.ResponseTEXT  
  5. 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 的差异了, 将上面的程序代码改为:

ASP/Visual Basic代码
  1. Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")  
  2. xmlhttp.Open "GET""http://diary.tw/tim/"False  
  3. xmlhttp.Send  
  4. Response.Write xmlhttp.ResponseTEXT  
  5. Set xmlhttp = Nothing  

Tags: asp xmlhttp

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2338

Asp正则验证是否有效的URL

这段代码可以用来判断用户输入的网址格式是否正确?

ASP/Visual Basic代码
  1. Function valid(ByVal str)    
  2. Dim temp,reg    
  3. Set reg = new regexp    
  4. reg.ignorecase=true    
  5. reg.global=true    
  6. temp = "^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$"  
  7. reg.pattern = temp    
  8. valid = reg.test(Trim(str))    
  9. Set reg = Nothing    
  10. End Function  

 调用方法:

ASP/Visual Basic代码
  1. if valid(url)=false then   
  2. response.Write("不是完整有效的URL!")   
  3. response.End()   
  4. end if  

原创代码,转载请注明出处,谢谢!

Tags: asp 正则表达式

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2370

PHP中逗号和点号的区别

比如:

1. echo 'abc'.'def'; //用点号连接字符串

2. echo 'abc','def'; //用逗号连接字符串

也许很多人都知道逗号要比点号快.但是不知道为什么.更不知道这两者到底有什么区别.

查看更多...

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2305

jquery页面中固定显示div层

这个是别人写的代码,自己实际用的时候对代码做了改动,主要需要新增一些功能! 

JavaScript代码
  1. /*任意位置浮动固定层*/  
  2. /*没剑(http://regedit.cnblogs.com) 2009-03-04*/  
  3. /*说明:可以让指定的层浮动到网页上的任何位置,当滚动条滚动时它会保持在当前位置不变,不会产生闪动*/  
  4. /*2009-06-10修改:重新修改插件实现固定浮动层的方式,使用一个大固定层来定位 
  5. /*2009-07-16修改:修正IE6下无法固定在top上的问题 
  6. /*09-11-5修改:当自定义层的绝对位置时,加上top为空值时的判断 
  7. 这次的方法偷自天涯新版页 
  8. 经多次测试,基本上没bug~ 
  9. 有问题的朋友欢迎到偶的博客http://regedit.cnblogs.com上提出 
  10. */  
  11. /*调用: 
  12. 1 无参数调用:默认浮动在右下角 
  13. $("#id").floatdiv(); 
  14.  
  15. 2 内置固定位置浮动 
  16. //右下角 
  17. $("#id").floatdiv("rightbottom"); 
  18. //左下角 
  19. $("#id").floatdiv("leftbottom"); 
  20. //右下角 
  21. $("#id").floatdiv("rightbottom"); 
  22. //左上角 
  23. $("#id").floatdiv("lefttop"); 
  24. //右上角 
  25. $("#id").floatdiv("righttop"); 
  26. //居中 
  27. $("#id").floatdiv("middle"); 
  28.  
  29. 另外新添加了四个新的固定位置方法 
  30.  
  31. middletop(居中置顶)、middlebottom(居中置低)、leftmiddle、rightmiddle 
  32.  
  33. 3 自定义位置浮动 
  34. $("#id").floatdiv({left:"10px",top:"10px"}); 
  35. 以上参数,设置浮动层在left 10个像素,top 10个像素的位置 
  36. */  
  37. jQuery.fn.floatdiv=function(location){  
  38.         //判断浏览器版本  
  39.     var isIE6=false;  
  40.     var Sys = {};  
  41.     var ua = navigator.userAgent.toLowerCase();  
  42.     var s;  
  43.     (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 0;  
  44.     if(Sys.ie && Sys.ie=="6.0"){  
  45.         isIE6=true;  
  46.     }  
  47.     var windowWidth,windowHeight;//窗口的高和宽  
  48.     //取得窗口的高和宽  
  49.     if (self.innerHeight) {  
  50.         windowWidth=self.innerWidth;  
  51.         windowHeight=self.innerHeight;  
  52.     }else if (document.documentElement&&document.documentElement.clientHeight) {  
  53.         windowWidth=document.documentElement.clientWidth;  
  54.         windowHeight=document.documentElement.clientHeight;  
  55.     } else if (document.body) {  
  56.         windowWidth=document.body.clientWidth;  
  57.         windowHeight=document.body.clientHeight;  
  58.     }  
  59.     return this.each(function(){  
  60.         var loc;//层的绝对定位位置  
  61.         var wrap=$("<div></div>");  
  62.         var top=-1;  
  63.         if(location==undefined || location.constructor == String){  
  64.             switch(location){  
  65.                 case("rightbottom")://右下角  
  66.                     loc={right:"0px",bottom:"0px"};  
  67.                     break;  
  68.                 case("leftbottom")://左下角  
  69.                     loc={left:"0px",bottom:"0px"};  
  70.                     break;    
  71.                 case("lefttop")://左上角  
  72.                     loc={left:"0px",top:"0px"};  
  73.                     top=0;  
  74.                     break;  
  75.                 case("righttop")://右上角  
  76.                     loc={right:"0px",top:"0px"};  
  77.                     top=0;  
  78.                     break;  
  79.                 case("middletop")://居中置顶  
  80.                     loc={left:windowWidth/2-$(this).width()/2+"px",top:"0px"};  
  81.                     top=0;  
  82.                     break;  
  83.                 case("middlebottom")://居中置低  
  84.                     loc={left:windowWidth/2-$(this).width()/2+"px",bottom:"0px"};  
  85.                     break;  
  86.                 case("leftmiddle")://左边居中  
  87.                     loc={left:"0px",top:windowHeight/2-$(this).height()/2+"px"};  
  88.                     top=windowHeight/2-$(this).height()/2;  
  89.                     break;  
  90.                 case("rightmiddle")://右边居中  
  91.                     loc={right:"0px",top:windowHeight/2-$(this).height()/2+"px"};  
  92.                     top=windowHeight/2-$(this).height()/2;  
  93.                     break;  
  94.                 case("middle")://居中  
  95.                     var l=0;//居左  
  96.                     var t=0;//居上  
  97.                     l=windowWidth/2-$(this).width()/2;  
  98.                     t=windowHeight/2-$(this).height()/2;  
  99.                     top=t;  
  100.                     loc={left:l+"px",top:t+"px"};  
  101.                     break;  
  102.                 default://默认为右下角  
  103.                     location="rightbottom";  
  104.                     loc={right:"0px",bottom:"0px"};  
  105.                     break;  
  106.             }  
  107.         }else{  
  108.             loc=location;  
  109.             alert(loc.bottom);  
  110.             var str=loc.top;  
  111.             //09-11-5修改:加上top为空值时的判断  
  112.             if (typeof(str)!= 'undefined'){  
  113.                 str=str.replace("px","");  
  114.                 top=str;  
  115.             }  
  116.         }  
  117.         /*fied ie6 css hack*/  
  118.         if(isIE6){  
  119.             if (top>=0)  
  120.             {  
  121.                 wrap=$("<div style=\"top:e­xpression(documentElement.scrollTop+"+top+");\"></div>");  
  122.             }else{  
  123.                 wrap=$("<div style=\"top:e­xpression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight);\"></div>");  
  124.             }  
  125.         }  
  126.         $("body").append(wrap);  
  127.           
  128.         wrap.css(loc).css({position:"fixed",  
  129.             z_index:"999"});  
  130.         if (isIE6)  
  131.         {  
  132.               
  133.             wrap.css("position","absolute");  
  134.             //没有加这个的话,ie6使用表达式时就会发现跳动现象  
  135.             //至于为什么要加这个,还有为什么要加nothing.txt这个,偶也不知道,希望知道的同学可以告诉我  
  136.             $("body").css("background-attachment","fixed").css("background-image","url(n1othing.txt)");  
  137.         }  
  138.         //将要固定的层添加到固定层里  
  139.         $(this).appendTo(wrap);  
  140.     });  
  141. };  

下载地址:http://files.cnblogs.com/regedit/jquery.floatdiv.rar

原文网址:http://www.cnblogs.com/regedit/archive/2008/03/11/1100170.html

Tags: javascript jquery

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3940

Asp利用MID分割字符示例

此代码相当有实际应用价值!

ASP/Visual Basic代码
  1. result=""      
  2. content="菊花名字的由来"      
  3. for i=1 to len(content)       
  4.     if i>1 then       
  5.         result=result"%"      
  6.     end if      
  7.     result=result&mid(content,i,1)       
  8. next       
  9. response.Write(result)    

原创代码,转载请注明出处!

Tags: asp

分类:技术文章 | 固定链接 | 评论: 2 | 引用: 0 | 查看次数: 2395

 广告位

↑返回顶部↑