Tuesday 15 March 2011

javascript - Using ZK: How to add a script into the head tag from java? -


Using ZK, I want to add a script to the head tag program.

How do I do this?

Finally I found a solution! In ZK's forum, one finds this possible solution:

"I know two ways:

1. Javascript file declaration Lang-addon.xml in

lang-addon.xml

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & lt; Language-addon & gt; ... & lt ;! - Path to the Bootstrap JavaScript Library - & gt; & lt; JavaScript src = "~. / Cyborg / less / bootstrap / js / bootstrap.min.js "Add manual to the Java code:  Type =" text / javascript "charset =" UTF-8 "/>  >  

if (see example of window) {window win = (window) view; page Ctrl + (PageCtrl) Win.getPage (); pc.addBeforeHeadTags ("& lt; script type = \" text / javascript \ "& gt;" + "(function (I, S, O, G, R, A, M) {I ['GoogleAnalyticsObject'] = R; I [R] = I [R] | Function () {"+" (i [r] .q = i [r] .q || []). Push ( Logic)}, i [r] .l = 1 * new date (); "+" a = s.createElement (o), "+" m = s.getElem EntsByTagName (o) [0]; "+" a .async = 1; a.src = g; m.parentNode.insertBefore (A, M) "+"}) "+" (window, document, 'script', '//www.google-analytics.com/analytics.js "+" GA ('send', 'pageview'); "+"; "+" GA ('create', '+ this.trackingID +', 'auto'); "+" Script & gt; ";} Other {New UiException (" This view should be implemented from model window component. "};}

From the API:

  zero org.zkoss.zk.ui.sys.PageCtrl.addBeforeHeadTags ( String tag)  

tag that will be generated inside the head element and before the default tag of JK. For example,

  ((PageCtrl ) Page .addBeforeHeadTags ("");  

"


No comments:

Post a Comment