<script>
setTimeout("document.write('" + place.address + "');",1);
</script>
같은 자바 스크립트 코드가있는 aspx 페이지가 있습니다. 코드에서 페이지에서 뭔가를 쓸 것입니다 1 ms의 매우 짧은 지연 후 것입니다. 일부 쿼리 문자열에 의해 실행 된 페이지를 가져 와서 출력을 얻는 다른 페이지를 만들었습니다. 문제는
- 간단히 document.write (place.address)를 쓰는 것으로 지연을 피할 수는 없습니다. 그것은 값을 얻기 위해 약간의 시간이 걸리므로 아무 것도 출력하지 않습니다. setTimeout에서 1ms의 지연 출력을 설정하면 항상 값을 반환합니다.
-
시스템을 사용하여 다른 페이지의 출력을 요청하면 .Net.WebClient wc = 새로운 System.Net.WebClient(); System.IO.StreamReader sr = new System.IO.StreamReader (wc.OpenRead ("http://localhost:4859/Default.aspx?lat="+ lat + "& lng ="+ lng)); 문자열 strData = sr.ReadToEnd();
누구든지 지연을 피하거나 클라이언트 요청을 지연 시켜서 원하는 값을 얻을 수 없습니다. 소스 코드
default.aspx의 js는
<script type="text/javascript">
var geocoder;
var address;
function initialize() {
geocoder = new GClientGeocoder();
var qs=new Querystring();
if(qs.get("lat") && qs.get("lng"))
{
geocoder.getLocations(new GLatLng(qs.get("lat"),qs.get("lng")),showAddress);
}
else
{
document.write("Invalid Access Or Not valid lat long is provided.");
}
}
function getAddress(overlay, latlng) {
if (latlng != null) {
address = latlng;
geocoder.getLocations(latlng, showAddress);
}
}
function showAddress(r) {
place = r.Placemark[0];
setTimeout("document.write('" + place.address + "');",1);
//document.write(place.address);
}
</script>
이며 requestClient.aspx의 코드는 다음과 같습니다.
System.Net.WebClient wc = new System.Net.WebClient();
System.IO.StreamReader sr = new System.IO.StreamReader(wc.OpenRead("http://localhost:4859/Default.aspx?lat=" + lat + "&lng=" + lng));
string strData = sr.ReadToEnd();
"원하는 출력 대신 문서의 소스 코드를 얻습니다"라는 의미는 무엇입니까? 당신은'setTimeout ("document.write ...'물건이나 ASPX- 코드 (Default.aspx의 마크 업)을 볼 수 있습니까? 나는 후자를 이해할 수 없으며 당신이 ** URL을 가져 오지 않았다고 생각합니다 하지만 파일 시스템에서 직접 파일 (IIS를 우회). – scherand