alert ("Browser does not support HTTP Request"); return; } var objInput=document.getElementById("title"); var url="save.php?"; var postdate="value="+objInput.value; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("POST",url,true); xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlHttp.send(postdate); }function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="200"){\
function pass(obj) {
window.location.href = "save.php?value=" + obj.value;
}
</script>save.php<?php
if(isset($_GET['value']))
echo $_GET['value'];
?>
这个的话 当前页面会执行save.php,达不到LZ要的效果,
实现这个要用ajax的,
onblur的时候异步请求save.php-->save.php输出要保存的内容-->前台获取内容,并赋值给title对话框~
//function pass(obj) {
//
// window.location.href = "save.php?value=" + obj.value;
//}
var xmlHttp;
function GetXmlHttpObject(){
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
} catch (e) {
//Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}function postValue(){
xmlHttp=GetXmlHttpObject();
if(xmlHttp==null) {
alert ("Browser does not support HTTP Request");
return;
}
var objInput=document.getElementById("title");
var url="save.php?";
var postdate="value="+objInput.value;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(postdate);
}function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="200"){\
var str_text=xmlHttp.responseText;
alert(str_text);
document.getElementById("title").value=str_text;
}
}
</script>
save.php
<?php
echo $_POST["value"];
?>
这里不小心加了个反斜杠借鉴的时候请删掉:function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="200"){\