JavaScript中addClass, removeClass, hasClass等方法的用法function hasClass(ele,cls) { return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));} function a……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2258浏览 2104个赞
这段代码类似于C#里的HtmlEncode函数,可以对html代码进行转码替换,如:>转换成>function htmlEntities(str) { return String(str).replace(/&/g, '&').replace(/</g, '<').replac……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2682浏览 2198个赞
C#处理Json格式文件的代码演示 JSON(全称为JavaScript Object Notation) 是一种轻量级的数据交换格式。它是基于JavaScript语法标准的一个子集。 JSON采用完全独立于语言的文本格式,可以很容易在各种网络、平台和程序之间传输。JSON的语法很简单,易于人阅读和编写,同时也易于机器解析和生成。转自:http://bl……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3018浏览 966个赞
C#通过jQuery实现无刷新评论提交 首先在数据库中就建三个字段的表用来存储用户名和评论信息,Id只是为了设置唯一标示,所以设置成整型自增字段就行了。 再建一个HTML页面,只需简单的拉几个html控件出来摆着就行,注意在页面顶部有个标签用来占位输出评论内容。&……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1350浏览 2509个赞
在一个对象上触发某类事件(比如单击onclick事件),如果此对象定义了此事件的处理程序,那么此事件就会调用这个处理程序,如果没有定义此事件处理程序或者事件返回true,那么这个事件会向这个对象的父级对象传播,从里到外,直至它被处理,挺起来感觉这么不可思议 什么是JS事件冒泡?……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2163浏览 2056个赞
简单的JavaScript邮件验证function checkMail(email){ var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (filter.test(email)) { return true; } retur……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1670浏览 2972个赞
asp.net中通过Jquery+Ajax+Json实现完全无刷新分页代码 html代码<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AjaxJson.asp……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1431浏览 654个赞
不适用javascript,在一个大图片加载出来之前使用一个loading的小图片替换,需要为图片添加class=loading.loading { background: url(loading.gif) no-repeat center center; }……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1660浏览 608个赞
JavaScript处理不同浏览器的鼠标点击事件// Browser detection var ie=document.all != null; //ie4var op7=navigator.userAgent.indexOf("opera")>0 && operaVersion() <= 7;……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1649浏览 1932个赞
Javascript显示和隐藏ul列表<ul id="rightNav"> <li> <h2 class="rightNavItem"><a href="#">Show & Hide</a></h2>……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2910浏览 550个赞
Javascript改变表单元素的背景,如改变文本框的背景function colorChange(formName,formItem){ document.forms[formName.name].elements[formItem.name].style.backgroundColor = "#FFFFFF";}……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3113浏览 464个赞
不适用javascript,完全通过php实现多级列表选择,列表数据从数据库获取A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql<? /* #……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2299浏览 1326个赞
本代码可以从数据库读取数据生成一个类似于windows的资源管理器的树形列表<?php // -*- C++ -*- /* Here are the database definitions (for Solid) that i use in this code. * It should not b……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1303浏览 2457个赞
JavaScript截断字符串,类似于substr(),只不过这个函数不会截断单词,在发生截断后,会添加一个省略号if (!function_exists('subsent')) { function subsent($string, $start = 0, $length = 0, $cap = '...……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1710浏览 2235个赞
JavaScript 10进制和16进制相互转换// convert base 10 to 16 (dec to hex)parseInt(10, 10).toString(16); // convert base 16 to 10parseInt('a', 16).toString(10)……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1808浏览 1741个赞
这段代码主要帮助你理解在javascript中如何使用命名空间// namespaced functionvar NAMESPACED = function (param){ var _privateVar = '_privateMethod loaded: '; var _privateMethod = function (……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1429浏览 2356个赞
javascript的window.open函数弹出窗口,并保持窗口在屏幕上居中显示function popup(url,name,windowWidth,windowHeight){ myleft=(screen.width)?(screen.width-windowWidth)/2:100; mytop=(screen.height)?(……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1738浏览 2288个赞
JavaScript对下拉列表的值进行排序function sortList(id) { var obj = document.getElementById("id"); var values = new Array(); for(var i = 0; i < obj.options.length; i++) { v……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1271浏览 2851个赞
JavaScript关闭页面不弹出提示消息框的方法parent.window.opener = null; parent.window.open("", "_self"); parent.window.close(); parent.window.location.href = ""……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2621浏览 1483个赞
JavaScript中遍历一个对象的属性,在控制台输出var object = { a:10; b:20; s:'hello'}; $.each(object, function(name, value) { console.log(name+':'+……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1287浏览 685个赞
JavaScript性能优化 – 类的方法和属性定义//常规定义方法,慢MyClass = function(){ this.localMethod = function(){ }}//通过prototype定义,快MyClass.prototype.localMethod = function(){ }……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2360浏览 2568个赞
php逐个字符读取文件范例代码,每次只读取一个字符<?php$file=fopen("welcome.txt","r") or exit("Unable to open file!");while (!feof($file)) { echo fgetc($file); }……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2318浏览 881个赞
在php里写入cookie非常简单,只需要使用setcookie函数即可,语法如下:setcookie(name, value, expire)下面是演示代码<?php$expire=time()+60*60*24*60;setcookie("user", "75271.com", $expire);……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1490浏览 1000个赞
php中删除cookie,可以通过让cookie马上过期来完成,下面的代码将cookie的过期时间设置为一小时前<?phpsetcookie("user", "", time()-3600);?>……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2877浏览 2514个赞
php中$_SESSION数组用于存储session数据,$_SESSION是全局的,所以在任何地方都可以调用<?phpsession_start();//storing session variable$_SESSION['views']=1;?> <html><body> &l……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2839浏览 436个赞
php清除和销毁session的代码下面的代码分别用户删除单个session值和全部session unset() 用于释放一个已经存在的session值.可以使用 session_destroy() 函数销毁全部session.<?phpunset($_SESSION……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1472浏览 1534个赞
php可以通过$_COOKIE 读取cookie,下面是演示代码<html><body> <?phpif (isset($_COOKIE["user"])) echo "Welcome " . $_COOKIE["user"] . "!<……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1845浏览 442个赞
本代码介绍了在php中如何获取表单提交的信息,并发送邮件 保存下面的html代码到:email.html文件<html> <head> <title>Simple Send Mail Form www.75271.com(脚本分享网)&l……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2754浏览 1336个赞
程序中用到了php的mail函数,该函数定义如下:bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )如果邮件发送成功返回True,否则返回False&……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2584浏览 1982个赞
php校验表单,检测字段是否为空,当表单中有未填写的字段,则会显示错误信息。<html><body><form METHOD="POST" ACTION="ErrorCheck.php"><h1>Contact Information</h1>&……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1999浏览 1995个赞
将表单的各个元素的name都设置成同一个数组对象既可以以数组的方式传递表单值<form method="post" action="arrayformdata.php"><label>Tags</label><input type="text" na……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2632浏览 928个赞
要遍历XML树,我们可以使用下面的代码<?php function walk_tree ($node, $depth = 0) { for ($i = 0, $indent = ''; $i < $depth; $i++) $indent .= ' ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3039浏览 2484个赞
网页提交textarea文本框数据到php后端代码范例,修改时注意修改表达的action和后端php网页的地址 html代码<html><head><title>A simple HTML form from www.75271.com(脚本……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1325浏览 209个赞
我们可以通过在程序的前后分别记录开始和结束时间,两个时间差就是程序的执行时间。<?php$long_str = "this is a test to see how much time md5 function takes to execute over this string"; // start timing from……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2635浏览 849个赞
php中可以通过rmdir()函数删除一个空目录<?php if (file_exists("/temp/test")) { rmdir("/temp/test"); print("Directory removed.\n");} else { print("Di……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2682浏览 171个赞
要让php接收表单传递过来的值,需要将表单的action设置为php后端页面的地址,$ _POST是PHP的全局数组保存所有收到的值。 html代码<html><head><title>脚本分享网(www.75271.com)演示代码<……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1355浏览 614个赞
下面的代码先判断目录是否存在,然后通过mkdir()函数在服务器上创建了一个目录<?php if (file_exists("/temp/test")) { print("Test Directory already exists.\n");} else { mkdir("/temp/t……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2429浏览 1204个赞
php中可以通过file_get_contents()函数将文件一次性读取到字符串中<?php $file = file_get_contents("/tmp/file.txt");print("Size of the file: ".strlen($file)."\n");?>……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1499浏览 2825个赞
在php中要一次输入多行字符,可以使用 >>>定界符方式,在 >>>后面跟着一个唯一标识符,换行输入多行字符串,最后使用同样的标识符结束字符串即可,下面是演示范例。$who = "World";echo <<<TEXTSo I said, "Hello $who"TEXT; ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2338浏览 1749个赞
php中可以通过file()函数将文件读取到数组中,数组中的元素即为文件的每行,file()函数通过”\n”按行分割文件保存到数组,所以数组每个元素都是以”\n”结尾,我们可以通过 rtrim()函数将其去除<?php $lines = file("/tmp/file.txt")……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2359浏览 598个赞
php中可以通过fopen()打开一个文件,第二个参数设置为”r”表示已只读方式打开,函数返回一个文件句柄,其它函数就可以通过这个文件句柄对文件进行不同方式的读取<?php $file = fopen("/tmp/file.txt", "r");print("Type o……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2132浏览 1663个赞
下面的代码通过array_shift()函数加while循环不断移除数组的第一个元素,直到数组为空<?php$alpha = array("a", "b", "c"); while ( count( $alpha ) ) { $val = array_shift( $alpha)……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1254浏览 578个赞
php中有两个函数用来判断数组中是否包含指定的键,分别是array_key_exists和isset array_key_exists语法如下array_key_exists($key, $array) 如果……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1905浏览 1473个赞
php通过array_unshift函数添加多个变量到数组前端,函数返回添加后的数组元素个数<?php $alpha = array("a", "b", "c");$final = array_unshift($alpha, "d","e");……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2777浏览 860个赞
php中你可以通过isset函数判断变量是否存在echo isset ($x); 如果变量存在并有值返回true,否则返回false……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2023浏览 897个赞