2013-09-24 2 views
0

내가있는 UIWebView에서 내 응용 프로그램에서 보여 두 가지 간단한 HTML 파일, 해당 코드가 있습니다 index.html을있는 UIWebView window.innerWidth = 0

<script> 
     var iWinWidth = window.innerWidth; 
     var iWinHeight = window.innerHeight; 

     alert(window.name + "\n iWinWidth="+iWinWidth+" iWinHeight="+iWinHeight); 
</script> 
<FRAMESET rows="704,..." cols="1024,..."> 
<FRAME SRC="2.html" name="contentFrame" noresize> 
</FRAMESET> 

및 2.html :

<html> 
<body> 

<script>   
      var iWinWidth = window.innerWidth; 
    var iWinHeight = window.innerHeight; 

     alert(window.name + "\n iWinWidth="+iWinWidth+" iWinHeight="+iWinHeight); </script> 

</body> 
</html> 

을 문제는 2.html window.innerWidth와 window.innerHeight는 0입니다. 이 문제를 해결하려면 어떻게해야합니까? 이 코드는 큰 프로그램에서 문제를 테스트하고 해결하기위한 작은 샘플이며 2.html 파일은 타사입니다. index.html을 변경하거나 2.html로 자바 스크립트를 삽입 할 수는 있지만 자체 스크립트를 변경하지는 않습니다. OBJ-C에서

로드 파일 :

documentPath=[[[NSBundle mainBundle] pathForResource:@"testFormats" ofType:@""] stringByAppendingPathComponent:documentPath]; 
NSURL *url = [NSURL fileURLWithPath:documentPath]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
[self.webView loadRequest:request]; 

답변

1

이 2.html 몸 태그를 스크립트를 넣어 당신이 몸에 onLoad를 얻을 때 창 크기 기능을 트리거보십시오.