.......
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
........
<form id="fabokeForm" method="GET" action="json.asp" accept-charset="GBK" target="hiddenIframe">
..... ......
</form>
<iframe id="hiddenIframe" name="hiddenIframe" width=0 height=0 style="display:none" frameborder=0 src="about:blank"></iframe>
var form = document.getElementById("fabokeForm");
/**/
var iframe = document.getElementById("hiddenIframe");
function iframeOnload(){
var html = "",json = null;
try{
var el = (iframe.contentWindow || iframe.contentDocument.parentWindow).document.body;
while(el && el.nodeType !== 3){
el = el.firstChild;
}
html = el.nodeValue ;
json = html ? eval("(" + html + ")") : false;
}catch(e){}
if(json){
if(json.data && json.data.title){
alert(json.data.title);
}else if (json.error){
alert(json.error || "上传失败。");
}
}
}
if(iframe.attachEvent){
iframe.attachEvent("onload",iframeOnload);
}else{
iframe.onload = iframeOnload;
}
//处理页面编码问题
if(navigator.userAgent.indexOf("MSIE") !== -1){
form.onsubmit = function(e){
document.charset='GBK';
}
window.onbeforeunload = function(){
document.charset='UTF-8';
}
}