nocache.js 파일의 dowcument.write 호출은 문서로드가 완료되지 않은 경우에만 작동합니다. 그렇지 않으면 document.write가 전체 문서를 덮어 씁니다. 마커 ID와 스크립트를 추가하는 제 코드
: 두 번째 부분에 대한
var script = document.createElement("script");
script.setAttribute("id", markerId);
$doc_0.getElementsByTagName("body")[0].appendChild(script);
합니다 (document.write를 호출 그 때문에
는 createElement와의 DOM 방법으로 대체 할 수있다 거의 nocache.js의 끝 부분). 응용 프로그램의 이름으로 "응용 프로그램을"교체 :
try {
var script = document.createElement("script");
script.setAttribute("defer", "defer");
script.innerHTML = "app.onInjectionDone('app')";
$doc_0.getElementsByTagName("body")[0].appendChild(script);
} catch (e) {
// Fallback if we want to use the original html page without embedding in IE
$doc_0.write('<script defer="defer">app.onInjectionDone(\'app\')<\/script>');
}
그래서,이 GWT에서 생성 한 코드에 패치 할 수있는 부분이었다. 사용자가 버튼을 클릭하면 응용 프로그램을 시작 부하와 이제 HTML 페이지 :
<html>
<head>
<!-- base url -->
<base href="http://localhost:8080/app/" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="static-gwt.css">
<title>APP</title>
<script type="text/javascript">
function startApp() {
if (document.createElement && document.getElementsByTagName) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'app/app.nocache.js';
var heads =document.getElementsByTagName('body');
if (heads && heads[0]) {
heads[0].appendChild(script);
triggerAppStart();
}
}
}
function triggerAppStart(){
try{
app.onInjectionDone('app');
if (!document.createEventObject) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent("DOMContentLoaded", true, true);
document.dispatchEvent(evt);
}
} catch (e) {
window.setTimeout('triggerAppStart()', 100);
}
}
</script>
</head>
<body>
<input type="button" onclick="startApp();return false;">
</body>
</html>
나는이 최선의 해결책 아니라는 것을 알고 있지만 그것은 지금까지 일을하는 유일한 방법입니다.
응용 프로그램의 기능과 Echo2 환경과의 상호 작용 방식에 따라 GWT 응용 프로그램을 iframe에로드 할 수 있습니다. –