GWT or GWT tab as an external library

I just want to download the GWT application by adding a script tag to the DOM, however, since the GWT linker uses document.write (), I cannot find a good way to do this. I found some hacks for this on different blogs, but they all seem to fail with the latest version of GWT. Any reasonable non-invasive approach for this comes to mind?

Clarification:

The usual way to run a GWT application on an html host page:

<script type="text/javascript" language="javascript" src="myapp.nocache.js"></script> 

This, of course, begins as soon as the page loads. I want to do this later:

function startapp() {
    var head = document.getElementsByTagName('head');
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('src', 'myapp.nocache.js');
    head[0].appendChild(s);
}
+5
source share
3 answers

Here is what seems to work so far:

Add this at the top of your App.gwt.xml:

<!-- Cross site linker -->
<inherits name="com.google.gwt.core.Core" />
<add-linker name="xs" />

( ) app.nocache.js :

1) $doc.write...

2) $doc.write, , . :

eval('window.__gwtStatsEvent && window.__gwtStatsEvent({' + 'moduleName:"app", sessionId:window.__gwtStatsSessionId, subSystem:"startup",' + 'evtGroup: "loadExternalRefs", millis:(new Date()).getTime(),' + 'type: "end"});' + 'window.__gwtStatsEvent && window.__gwtStatsEvent({' + 'moduleName:"app", sessionId:window.__gwtStatsSessionId, subSystem:"startup",' + 'evtGroup: "moduleStartup", millis:(new Date()).getTime(),' + 'type: "moduleRequested"});');

3) .

document.body.appendChild(document.createElement('script')).src=base + strongName + ".cache.js";

, $doc.write .

:

<a href="javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://abc.com/app.nocache.js';})();">My App</a>
+5

, , document.write. , , (, , ).

, , :

script ( )

script GWT. javascript, IFrame , src IFrame HTML , GWT.

, , GWT . , , IFrame , .

, window.postMessage window.addEventListener GWT IFrame javascript ( JSNI GWT.)

, postMessage , , , , .

+1

, javascript , inorder ..

dom JWT- js. JavaScript- GWT, , DOM .

? GWT, - : :

<script src="gwtmoduleloader.js"></script>

gwtmoduleloader.js , , , gwt.

GWT , sevlet

document.write('<script src="myapp.nocache.js"></script>') 

or else quietly return.

When the browser evaluates the contents of gwtmoduleloader.js, it can find document.write for another script (in your case the gwt module), which it will load and evaluate. This, therefore, is a conditional load and can be achieved before loading the body.

Is this what you were looking for?

0
source

All Articles