IE에서 실행할 때이 코드가 올바르게 작동합니다. activeX 사용으로 인해 차단 된 콘텐츠를 허용하라는 요청이 표시됩니다. 하지만 파이어 폭스와 다른 브라우저에서 실행하면 아무것도 얻지 못합니다. 친절하게 도와주세요.Internet Explorer에서 열 때이 코드가 제대로 작동하지만 Firefox 나 다른 브라우저에서 열 때 작동하지 않습니다.
var httpRequest;
try
{
httpRequest = new XMLHttpRequest(); // Mozilla, Safari, etc
}
catch(trymicrosoft)
{
try
{
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(oldermicrosoft)
{
try
{
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(failed)
{
httpRequest = false;
}
}
}
if(!httpRequest)
{
alert('Your browser does not support Ajax.');
return false;
}
//===============================
// Action http_request
var finaltxt;
//do{
httpRequest.onreadystatechange = function()
{
if(httpRequest.readyState == 4)
if(httpRequest.status == 200)
{
var txt = httpRequest.responseText;
var index = txt.search(/regular/i);
var index1 = txt.search(/to see hours/i);
finaltxt = txt.substring(index,index1);
document.write("<IMG " +"SRC='web2.jpg'>");
document.write("<br>"+ finaltxt.fontsize(2) + "<br>");
return finaltxt;
}
else
return finaltxt;
}
httpRequest.open('GET','http://xyz',true);
httpRequest.send(null);
return finaltxt;
크로스 브라우저 문제는이 문서를 참조하십시오 : 당신이 교차 알아서 할 필요가 없습니다 http://www.ilinsky.com/articles/XMLHttpRequest/ – Mrchief
jQuery를 같은 라이브러리를 사용을 브라우저 문제. –
자바 스크립트 라이브러리를 사용하지 않는 이유가 있습니까? jQuery는 이것을 멋지게 만들 것입니다. 어쩌면 이것이 학교 프로젝트일까요? 또한 1) document.write()는 매우 유해한 것으로 간주되며 2) 요소 및 특성 이름 (img, src)은 더 나은 표준 준수를 위해 소문자 여야합니다. –