Java Code Examples for com.google.gwt.dom.client.ScriptElement#setAttribute()
The following examples show how to use
com.google.gwt.dom.client.ScriptElement#setAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomAnalyticsImpl.java From core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void init(String userAccount) { Element firstScript = Document.get().getElementsByTagName("script").getItem(0); ScriptElement config = Document.get().createScriptElement( "var _gaq = _gaq || [];_gaq.push(['_setAccount', '" + userAccount + "']);_gaq.push (['_gat._anonymizeIp']);_gaq.push(['_trackPageview']);"); firstScript.getParentNode().insertBefore(config, firstScript); ScriptElement script = Document.get().createScriptElement(); // Add the google analytics script. script.setSrc(("https:".equals(Window.Location.getProtocol()) ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js"); script.setType("text/javascript"); script.setAttribute("async", "true"); firstScript.getParentNode().insertBefore(script, firstScript); }
Example 2
Source File: GoogleAnalyticsImpl.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void loadAnalyticsScript() { ScriptElement script = Document.get().createScriptElement(); script.setSrc(GoogleAnalyticsImpl.SCRIPT_URL); script.setType("text/javascript"); script.setAttribute("async", "true"); Element firstScript = Document.get().getElementsByTagName("script").getItem(0); firstScript.getParentNode().insertBefore(script, firstScript); }