-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How can I do this?
I know two ways for that:
1.Put the declarartion of the javascript file in the lang-addon.xml
lang-addon.xml
<?xml version="1.0" encoding="UTF-8"?>
<language-addon>
. . .
<!-- 4. Path to Bootstrap javascript library -->
<javascript src="~./cyborg/less/bootstrap/js/bootstrap.min.js" type="text/javascript" charset="UTF-8" />
</language-addon>
2. Add manual in java code:
if (view instanceof Window) {
Window win = (Window) view;
PageCtrl pc = (PageCtrl) win.getPage();
pc.addBeforeHeadTags("<script type=\"text/javascript\">" + "(function(i,s,o,g,r,a,m)"
+ "{i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){"
+ "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();" + "a=s.createElement(o),"
+ "m=s.getElementsByTagName(o)[0];" + "a.async=1;a.src=g;m.parentNode.insertBefore(a,m)" + "})"
+ "(window,document,'script','//www.google-analytics.com/analytics.js','ga');" + "ga('create', "
+ this.trackingID + ", 'auto'); " + "ga('send', 'pageview');" + "</script>");
} else {
throw new UiException("This view model must be applied from a Window component.");
}
from api:
void org.zkoss.zk.ui.sys.PageCtrl.addBeforeHeadTags(String tags)
Adds the tags that will be generated inside the head element and before ZK's default tags. For example,
((PageCtrl)page).addBeforeHeadTags("");
best Stephan
Asked: 2015-03-18 13:34:42 +0800
Seen: 50 times
Last updated: Mar 18 '15
Theme javascript wpd file not found
Problem generating label value dynamically with JavaScript
Page as ZUL component, multiple instances of the same VM on one page
zk.wpd JS error, with window inside window
Unable to get default printer name while using applet
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?