1

Detect Browser in zk.xml

asked 2014-05-07 10:25:37 +0800

salbader gravatar image salbader
15 5

Hello, is there any solution to detect the browser in the zk.xml? Because i have a ie8 customized css file which should only be loaded when ie8 is used.

this is my solution at index.html

   jQuery(document).ready(function() {

          if ($.browser.msie){
            if ($.browser.version==8){
                alert("test");
            }


          }

     });
delete flag offensive retag edit

Comments

4 Answers

Sort by » oldest newest most voted
2

answered 2014-05-07 10:38:51 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

updated 2014-05-07 12:45:08 +0800

You can do that in java :

Execution exec = Executions.getCurrent();
exec.getBrowser()// => Returns the name of the browser, or null if not identifiable.
exec.getBrowser(String name) // => Returns the version of the given browser name, or null if the client is not the given browsers.

More info you can find in the Execution class.

Providing Theme Resources
After switching to another theme, ThemeProvider is responsible for getting the correct stylesheets to the client. This is done by manipulating the list of widget stylesheets comprising the theme. Web developers could create a custom ThemeProvider to change the caching for the widget stylesheets, inject additional widget stylesheets, reject unwanted widget stylesheets, and/or replace some widget stylesheets with another set.

You can specify any number of theme-uri as follows.

<desktop-config>    
    <theme-uri>/my/blue**.css</theme-uri>    
    <theme-uri>/my/second.css</theme-uri>
</desktop-config>

If you want to replace a default theme, you have to use theme-uri with disable-theme-uri. Please refer to ZK Developer's Reference for more information.

Summary :

Write your own ThemeProvider where you switch the css when you find a IE8.
An example from zk is here.

Greetz chill.

link publish delete flag offensive edit

Comments

thanks for your answer.

salbader ( 2014-05-07 10:59:47 +0800 )edit

+1 for write answer

sitansu ( 2014-05-07 11:35:27 +0800 )edit

an how should i set my css file for ie8? i can t find a solution for this.

salbader ( 2014-05-07 11:42:42 +0800 )edit

Is it only a css file or a complete theme with different name?

chillworld ( 2014-05-07 12:20:34 +0800 )edit

only one css file. in my index.html the detection of the browser works. but the append mehtod does not append the css file

if ($.browser.msie){ if ($.browser.version==8){ $('head').append('<link href='styles/myStyles.css' type='text/css' rel='stylesheet'/>') }
}

salbader ( 2014-05-07 12:35:02 +0800 )edit
0

answered 2014-05-07 14:11:30 +0800

salbader gravatar image salbader
15 5

updated 2014-05-07 14:16:45 +0800

Hello Chill, thanks for the example.but what is wrong with my quick solution? i think the "?" is a problem because ff loads the css too

        jQuery(document).ready(function() {
      if ($.browser.msie){
            if ($.browser.version==8){
                $('head').append('<?link href='styles/customized.css'?/>');         

            }
      }
     });


                }
link publish delete flag offensive edit
0

answered 2014-05-07 14:39:48 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

updated 2014-05-07 14:42:18 +0800

I can be mistaken but don't you have to do that for every page then?
your problem isn't the ? but the '. You declare 2 Strings with something he can't understand in the middle.
You must do :

append('<?link href=\\'styles/customized.css\\'?/>');

(I posted as answer cause in comment the codeline was terrible)

Greetz chill.

link publish delete flag offensive edit

Comments

your solution does not work maybe you took me wrong. my problem is that the css is always rendered. when ff is loading too. i think i have too fix it server side. i declare the customized.css in the zul.xml and when another browser then ie8 is used i drop this css. i will try and tell you.

salbader ( 2014-05-09 09:40:53 +0800 )edit
0

answered 2014-05-12 13:34:07 +0800

salbader gravatar image salbader
15 5

thanks chill. now it works with the themeProvider Solution best greets

link publish delete flag offensive edit

Comments

your welcome.

chillworld ( 2014-05-12 14:07:19 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-05-07 10:25:37 +0800

Seen: 50 times

Last updated: May 12 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More