-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I have a requirement that needs different style definitions for the different browsers. In XHTML it is possible to use "IE Conditional Comments" (eg. <!--[if IE]> Internet Explorer <![endif]-->)
If I try this in a zul-File the comments are ignored.
Here are my example:
<zk> <style> .bg-div {background: green; margin: 10px} </style> <!--[if IE]> <style> .bg-div {background: red; margin: 10px} </style> <![endif]--> <div sclass="bg-div" width="100%" height="500px" /> </zk>
thanks and regards,
Gunter
Hi Gunter
I create a sample
<zk> <style if="${execution.explorer}"> .myLabel { color: blue; } </style> <style unless="${execution.explorer}"> .myLabel { color: red; } </style> <label value="test" sclass="myLabel"/> </zk>
This post was really helpful, but I had a need to test specifically for IE6 - and org.zkoss.ui.Execution and org.zkoss.ui.http.ExecutionImpl only have an isExplorer() and an isExplorer7() method.
Those classes do contain a generic "boolean getTypeOfBrowser(String)" method, but alas because of that signature you can't use it from an EL expression - EL relies on maps for indexed properties.
After some tinkering, I came up with the following additional method that I added to my local copies of ExecutionImpl.java class and Execution.java interface :
@SuppressWarnings("serial") public Map<String, Boolean> getBrowserType() { return new HashMap<String, Boolean>() { @Override public Boolean get(Object type) { return isBrowser((String) type); } }; }
if="${execution.browserType.ie6}"
or
if="${execution.browserType['ie6']}"
Hi florimon,
Here are another sample
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?> <zk> gecko: ${c:isGecko()} <separator/> gecko2: ${c:browser('gecko2')} <separator/> gecko3: ${c:isGecko3()} <separator/> ie: ${c:isExplorer()} <separator/> ie7: ${c:isExplorer7()} <separator/> ie8: ${c:browser('ie8')} <separator/> safari: ${c:isSafari()} <separator/> opera: ${c:isOpera()} <separator/> </zk>
great thanks
id used it like
<script if="${c:browser('ie6')}" src="IE6version.js"></script>
<script if="$" src="LongScript.js"></script>
Asked: 2010-05-19 04:34:45 +0800
Seen: 1,390 times
Last updated: Mar 20 '12