<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<div id="test">
<pre>
休息休息
</pre>
</div>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
var connector = (function(){
var connector = null;
if(window.XMLHttpRequest){
connector = new XMLHttpRequest();
}else if(window.ActiveXObject){
connector = new ActiveXObject('Microsoft.XMLHTTP');
}
return connector;
})();
var innerText = document.body.innerText ? 'innerText' : 'textContent';
var handler = function(response){
document.getElementById('test').getElementsByTagName('pre')[0][innerText] = response;
}
connector.onreadystatechange = (function(callback){
return function(){
if(connector.readyState == 4){//这里connector.status == 200都省了。
callback.call(connector,connector.responseText);
}
}
})(handler);
connector.open('GET',location.href,true);//发送到本页面
connector.send();
</script>
</body>
</html>
用js判断页面是否加载完成
这可以通过用document.onreadystatechange的方法来监听状态改变, 然后用document.readyState == “complete”判断是否加载完成。
可以采用2个div,其中一个在前面,一个在后面,前面的先显示,里面放一个页面正在加载中的小图片,小flash都可以。
后面的div开始加载内容,在页面上随时监测加载是否完毕,如果加载完毕,将前面的div隐藏,后面的div提到前面来即可。
复制代码
document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法.
function subSomething()
{
if(document.readyState == “Loaded”) //当页面加载状态
{
//Load提示第一个div隐藏掉
//将Html显示
}
复制代码
复制代码
页面加载readyState的五种状态 原文如下:
0: (Uninitialized) the send( ) method has not yet been invoked.
0 - (未初始化)还没有调用send()方法
1: (Loading) the send( ) method has been invoked, request in progress.
1 - (载入)已调用send()方法,正在发送请求
2: (Loaded) the send( ) method has completed, entire response received.
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
3: (Interactive) the response is being parsed. 4: (Completed) the response has been parsed, is ready for harvesting.
3 - (交互)正在解析响应内容
4: (Completed) the response has been parsed, is ready for harvesting.
4 - (完成)响应内容解析完成,可以在客户端调用了
http://www.cnblogs.com/e4ky/p/VS2015_Android_01.html
<!--js方法创建下拉框-->
<input id="cc" name="dept">
[javascript] view plain copy 在CODE上查看代码片派生到我的代码片
$('#cc').combobox({
data: [
{ "id": 1, "value": "条目1" },
{ "id": 2, "value": "条目2" },
{ "id": 3, "value": "条目3" },
{ "id": 4, "value": "条目4" },
{ "id": 5, "value": "条目5" }
],
valueField: 'id',
textField: 'value',
selectOnNavigation: false,
filter: function (q, row) { //filter函数 传连个参数,第一个参数是你要过滤的字符串,第二个是行参数
var opts = $(this).combobox('options');//获取的是textbox对象
return row[opts.textField].toLowerCase().indexOf(q.toLowerCase()) == 0;
},
onSelect: function (k) { //onSelect方法传的参数是一个数组
selectValueId.value = k["value"];
selectValueId.id = k["id"];
var opts = $(this).combobox('panel'); //获取的是下拉框对象
}
});
JQuery EasyUI combobox动态添加option
<input class="easyui-combobox" id="rwlb" name="rwlb" style="width:435px" data-options="valueField:'id', textField:'text', panelHeight:'auto'" >
方法一:
1 var data, json;
2 json = '[{"id":"年计划","text":"年计划","selected":true}]';
3 data = $.parseJSON(json);
4 $("#rwlb").combobox("loadData", data);
方法二:
1 var data,json;
2 data = [];
3 data.push({ "text": "测试", "id": 100 });
4 $("#rwlb").combobox("loadData", data);
<html>
<head>
<title>LIGHTBOX EXAMPLE</title>
<style>
.black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; padding: 16px; border: 16px solid orange; background-color: white; z-index:1002; overflow: auto; } </style>
</head>
<body>
<p>可以根据自己要求修改css样式<a href="javascript:void(0)" οnclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">点击这里打开窗口</a></p>
<div id="light" class="white_content">
This is the lightbox content.
<a href="javascript:void(0)" οnclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">
Close</a></div>
<div id="fade" class="black_overlay">
</div>
</body>
</html>
JSON.stringify 功能为从一个对象解析为字符串
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<div id="test">
<pre>
休息休息
</pre>
</div>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
var connector = (function(){
var connector = null;
if(window.XMLHttpRequest){
connector = new XMLHttpRequest();
}else if(window.ActiveXObject){
connector = new ActiveXObject('Microsoft.XMLHTTP');
}
return connector;
})();
var innerText = document.body.innerText ? 'innerText' : 'textContent';
var handler = function(response){
document.getElementById('test').getElementsByTagName('pre')[0][innerText] = response;
}
connector.onreadystatechange = (function(callback){
return function(){
if(connector.readyState == 4){//这里connector.status == 200都省了。
callback.call(connector,connector.responseText);
}
}
})(handler);
connector.open('GET',location.href,true);//发送到本页面
connector.send();
</script>
</body>
</html>
用js判断页面是否加载完成
这可以通过用document.onreadystatechange的方法来监听状态改变, 然后用document.readyState == “complete”判断是否加载完成。
可以采用2个div,其中一个在前面,一个在后面,前面的先显示,里面放一个页面正在加载中的小图片,小flash都可以。
后面的div开始加载内容,在页面上随时监测加载是否完毕,如果加载完毕,将前面的div隐藏,后面的div提到前面来即可。
复制代码
document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法.
function subSomething()
{
if(document.readyState == “Loaded”) //当页面加载状态
{
//Load提示第一个div隐藏掉
//将Html显示
}
复制代码
复制代码
页面加载readyState的五种状态 原文如下:
0: (Uninitialized) the send( ) method has not yet been invoked.
0 - (未初始化)还没有调用send()方法
1: (Loading) the send( ) method has been invoked, request in progress.
1 - (载入)已调用send()方法,正在发送请求
2: (Loaded) the send( ) method has completed, entire response received.
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
3: (Interactive) the response is being parsed. 4: (Completed) the response has been parsed, is ready for harvesting.
3 - (交互)正在解析响应内容
4: (Completed) the response has been parsed, is ready for harvesting.
4 - (完成)响应内容解析完成,可以在客户端调用了
http://www.cnblogs.com/e4ky/p/VS2015_Android_01.html
<!--js方法创建下拉框-->
<input id="cc" name="dept">
[javascript] view plain copy 在CODE上查看代码片派生到我的代码片
$('#cc').combobox({
data: [
{ "id": 1, "value": "条目1" },
{ "id": 2, "value": "条目2" },
{ "id": 3, "value": "条目3" },
{ "id": 4, "value": "条目4" },
{ "id": 5, "value": "条目5" }
],
valueField: 'id',
textField: 'value',
selectOnNavigation: false,
filter: function (q, row) { //filter函数 传连个参数,第一个参数是你要过滤的字符串,第二个是行参数
var opts = $(this).combobox('options');//获取的是textbox对象
return row[opts.textField].toLowerCase().indexOf(q.toLowerCase()) == 0;
},
onSelect: function (k) { //onSelect方法传的参数是一个数组
selectValueId.value = k["value"];
selectValueId.id = k["id"];
var opts = $(this).combobox('panel'); //获取的是下拉框对象
}
});
JQuery EasyUI combobox动态添加option
<input class="easyui-combobox" id="rwlb" name="rwlb" style="width:435px" data-options="valueField:'id', textField:'text', panelHeight:'auto'" >
方法一:
1 var data, json;
2 json = '[{"id":"年计划","text":"年计划","selected":true}]';
3 data = $.parseJSON(json);
4 $("#rwlb").combobox("loadData", data);
方法二:
1 var data,json;
2 data = [];
3 data.push({ "text": "测试", "id": 100 });
4 $("#rwlb").combobox("loadData", data);
<html>
<head>
<title>LIGHTBOX EXAMPLE</title>
<style>
.black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; padding: 16px; border: 16px solid orange; background-color: white; z-index:1002; overflow: auto; } </style>
</head>
<body>
<p>可以根据自己要求修改css样式<a href="javascript:void(0)" οnclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">点击这里打开窗口</a></p>
<div id="light" class="white_content">
This is the lightbox content.
<a href="javascript:void(0)" οnclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">
Close</a></div>
<div id="fade" class="black_overlay">
</div>
</body>
</html>
JSON.stringify 功能为从一个对象解析为字符串