今天遇到个问题,需要使框架中的链接在新窗口中打开,但是被嵌入的框架页面中连接n多,有没有个简单的代码一下就搞定呢?其实很简单,在被嵌入框架的页面的<head></head>之间加入<base target=”_blank”>,问题就解决了。呵呵,这些再简单不过的东西可不能忘记了啊。
-
批量设置连接在新窗口打开
[网页编程]post by 寒川 / 2010-3-4 13:22 Thursday -
分享一个js判断中文字符的正则
[网页编程]post by 寒川 / 2010-2-21 22:04 Sunday真是书到用时方恨少啊,今天弄一个禁止中文字符注册的代码时被难住了,好在还有网络,百度谷歌病一下就出来了。
<script>
function checkchinese(str)
{
var re = /[^\u4e00-\u9fa5]/;
if(re.test(str)) return false;
return true;
}if(checkchinese("啊啊啊"))
{
alert("很明显,有中文字符。");
}
else
{
alert("很明显,没有中文字符。");
}
</script> -
session实现两个页面处理由一个form提交的数据
[网页编程]post by 寒川 / 2010-1-21 10:46 Thursday近日有朋友问道如何才能一个form提交数据给两个页面处理,想想其实应该比较简单的。先是一个页面获取form提交过来的数据直接处理,处理完成后将数 据记录在session中,传递给另一个页面就ok了。不管是asp还是php都能简单地实现。当然,在第二个页面处理完成后记得将session清除 哦。。
-
简单的php验证码验证程序
[网页编程]post by 寒川 / 2009-11-4 11:47 Wednesdaycode.php
<?php
//生成验证码图片
Header("Content-type: image/PNG");
srand((double)microtime()*1000000);//播下一个生成随机数字的种子,以方便下面随机数生成的使用
session_start();//将随机数存入session中
$_SESSION['code']="";
$image = imagecreate(55,20); //制定图片背景大小
$black = ImageColorAllocate($image, 0,0,0); //设定三种颜色
$white = ImageColorAllocate($image, 255,255,255);
$gray = ImageColorAllocate($image, 255,255,255);
imagefill($image,0,0,$gray); //采用区域填充法,设定(0,0)
while(($code=rand()%10000)<1000);//设置位数
$_SESSION['code']=$code;
imagestring($image, 5, 10, 3, $code, $black);
ImagePNG($image);
ImageDestroy($image);
?>test.php
<?php
session_start();
if(!isset($_POST['code'])) $_POST['code']="";
if($_POST['code']=='')
{
?>
<form method="post" action="" name="form">
<input type="text" name="code"><img src="code.php">
<input input type="submit" value=" 登 录"">
</form>
<?php
}
else if ($_POST['code']==$_SESSION['code']) echo '验证码验证成功!'; else print'验证码错误!';
?> -
php中定义变量
post by 寒川 / 2009-10-20 9:59 Tuesday虽然php没强制要求定义变量,但是当配置文件的error调到拉最高级别时,往往会出些警告信息。如:"Warning: Undefined variable:test ”,解决办法可以用if(!isset($test)) $test="";这种方法来解决。
