让页面在打开时自动刷新

1
2
3
4
5
6
7
<script>
function window.onload() {
if (location.href.indexOf('#reloaded') == -1) {
location.href = location.href + "#reloaded"location.reload()
}
}
</script>

-————————————————————–

我的网页的图片较多,而服务器也不是很好,所以每次打开网页后总有一、两幅图片无法显示,但刷新一遍后又全部可显示了。
不想让浏览网页的人每次都点“刷新”按钮,请问如何在网页中加入一些代码,让网页在打开后又自动刷新一次?
-————————————————————–

把下面代码加在<head></head>之间
<meta http-equiv=refresh content=5 > //每隔5秒刷新一次
-————————————————————–

Read More

Linux apache 添加 mod_rewrite模块

apache已安装完毕,手动添加mod_rewrite模块
#find . -name mod_rewrite.c //在apache的源码安装目录中寻找mod_rewrite.c文件
#cd modules/mappers/ //进入包含mod_rewrite.c文件的目录
#/usr/share/apache-2.2.11/bin/apxs -c mod_rewrite.c //apxs应指定绝对路径,在你当前正在使用apache的bin目录里
#/usr/share/apache-2.2.11/bin/apxs -i -a -n rewrite mod_rewrite.la
如果没有什么错误的话,应该在你的apache的modules目录中编译出一个mod_rewrite.so文件。
编辑httpd.conf文件,确认httpd.conf中已经包含mod_rewrite.so的加载语句,如下:
LoadModule rewrite_module modules/mod_rewrite.so
这时,你的apache应该已经支持rewrite了。over!
注:完成之后,记得重启服务器apache。

Read More

JSON对象和JSON字符串以及JSON.parse函数的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JSON.parse()</title>
<script type="text/javascript">
//示例1:此示例使用 JSON.parse 将 JSON 字符串转换为对象
var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}';//JSON 字符串
var contact = JSON.parse(jsontext);
document.write(contact.surname + ", " + contact.firstname + ", "+ contact.phone);

//示例2:和实例1是一样的效果
var jsontext2 = {"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]};//JSON 对象
//var contact2 = JSON.parse(jsontext2);
document.write("<br /><br />"+jsontext2.surname + ", " + jsontext2.firstname + ", "+ jsontext2.phone);
</script>
</head>
<body>
</body>
</html>

Read More

JQuery中$.ajax()方法参数详解

url:要求为String类型的参数,(默认为当前页地址)发送请求的地址。

type:要求为String类型的参数,请求方式(post或get)默认为get。注意其他http请求方法,例如put和delete也可以使用,但仅部分浏览器支持。

timeout:要求为Number类型的参数,设置请求超时时间(毫秒)。此设置将覆盖$.ajaxSetup()方法的全局设置。

async:要求为Boolean类型的参数,默认设置为true,所有请求均为异步请求。如果需要发送同步请求,请将此选项设置为false。注意,同步请求将锁住浏览器,用户其他操作必须等待请求完成才可以执行。

Read More