• Resolved Adrian

    (@adriandw)


    I have some pages which don’t work on IE8 on XP.
    They do however work with Opera.
    When I tried the code below without the hidefrom opera, it displayed the warning to Opera users even though the site works with Opera.
    So I added hidefrom opera.
    But now the warning doesn’t display for ie users.
    Have I made a mistake or is there a bug?

    Here’s my code:

    [showto browser="msie ie5 ie6 ie7 ie8"][hidefrom browser="opera"]span style='color:maroon'>***We're sorry but the maps on this website don't work with the version of Internet Explorer that you appear to be using. <br/>We're looking at the problem and will fix it if we can. <br/>In the meantime, other browsers which have been tested successfully include <a href="https://www.google.com/chrome" title="download Google Chrome" target="_blank">Google Chrome</a>, <a href="http://www.mozilla.org/en-US/firefox/new/" title="download Firefox" target="_blank">Firefox</a> and <a href="http://www.opera.com/" title="download Opera" target="_blank">Opera</a>.***</span>[/hidefrom][/showto]

    http://ww.wp.xz.cn/plugins/browser-body-classes-with-shortcodes/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author thomstark

    (@thomstark)

    Would you be able to send me a link to the page?

    Plugin Author thomstark

    (@thomstark)

    I’ve thrown your code into a test page on one of my sites and it is working as it should (hides message from Opera, shows only to MSIE). But it may be an Opera version issue. Try adding chrome to your hidefrom shortcode, like this: [hidefrom browser=”opera chrome”]

    Opera uses Chrome in some versions, so it may work to cover your bases like that. Let me know if that does not resolve your problem.

    But of course, it also works for me on my page when I remove the hidefrom shortcode altogether. The message doesn’t display in Opera if I only use the showto MSIE code. So it may be something strange happening with the older platform. In Opera, have a look at the source code for that page, and tell me what classes appear in the <body> tag.

    Plugin Author thomstark

    (@thomstark)

    Adding “chrome” to your hidefrom shortcode should resolve your problem, but if not, worst case scenario you can do a CSS workaround.

    You would add this to your span: <span style=’color:maroon’ class=”hide-opera”>

    Then add this to your CSS stylesheet:

    body.opera .hide-opera, body.chrome .hide-opera, {display:none}

    Thread Starter Adrian

    (@adriandw)

    Many thanks for your suggestions.

    I think I’ve found my own answer:
    I’m using WP SuperCache.
    The first time a page is served, WP Super Cache caches the generated HTML.
    So whichever browser visits that page first, all other visitors receive the same same generated text whatever browser they are using.

    This obviously defeats the object of the plugin, so I guess I will either have to disable caching for the page(s) where I want the warning to appear, or find another solution.

    Thread Starter Adrian

    (@adriandw)

    I (temporarily) disabled caching on my site, and I made a new page with the following code:

    [showto browser="ie5, ie6, ie7, ie8"][hidefrom browser="chrome"]<span style='color:maroon'>***We're sorry but the maps on this website don't work with the version of Internet Explorer that you appear to be using. <br/>We're looking at the problem and will fix it if we can. <br/>In the meantime, other browsers which have been tested successfully include <a href="https://www.google.com/chrome" title="download Google Chrome" target="_blank">Google Chrome</a>, <a href="http://www.mozilla.org/en-US/firefox/new/" title="download Firefox" target="_blank">Firefox</a> and <a href="http://www.opera.com/" title="download Opera" target="_blank">Opera</a>.***</span>[hidefrom][/showto]
    
    Your browser is
    [showto browser="chrome"] Chrome,[/showto]
    [showto browser="firefox"] Firefox,[/showto]
    
    [showto browser="opera"] Opera,[/showto]
    [showto browser="safari"] Safari,[/showto]
    [showto browser="ie8"] Internet Explorer 8,[/showto]
    [showto browser="ipad"] iPad[/showto]

    The page is http://compton.parish.hants.gov.uk/about/this-website/browser-type/

    Without caching, it is working as expected, except that
    a) Opera 18 on Windows XP and on OS X is identified as Chrome (and I know it uses the Chrome rendering engine)

    b) Chrome on the iPad is identified as Safari, iPad (and I know Chrome on IOS 7 uses the same rendering engine as Safari).

    However, whatismybrowser.com can correctly tell the difference between all the above browsers.

    Feel free to have a look at my page, but I may be changing it, as I work towards a solution that allows me to cache as many pages as possible.

    Plugin Author thomstark

    (@thomstark)

    Sorry for the delay. Am away for the holidays. I appreciate your feedback on this and I’ll attempt to tweak it for best accuracy. It’s hard to cover all the bases with different versions using different engines, etc.

    Thread Starter Adrian

    (@adriandw)

    Because any code implemented in php is executed on the host, the generated html is liable to be cached by WP Super Cache, and therefore the shortcodes may note have the desired effect.
    Because of caching, the test for the browser type needs to be done in javascript in the browser.
    So I dropped the “Browser Body Classes with Shortcodes” and use the following approach based on bowser from Github: https://github.com/ded/bowser

    I put this call in the page’s head:
    <script src="http://..pathto../bowser.min.js" type="text/javascript"></script>

    and code like this in the body of the page to enable display of the browser warning paragraph:

    <p id="ie8" style='color:maroon;display:none'>We're sorry, but the maps on this page and on this website aren't displayed by the version of Internet Explorer which you appear to be using. </p>
    [raw]
    <script type="text/javascript">
    if (bowser.msie && bowser.version <= 8) {
    ie8.style.display="";
    };
    </script>
    [/raw]

    The live page is at http://compton.parish.hants.gov.uk/about/maps/open-spaces/

    This page also displays a conditional message, using the same javascript, if viewed on IE Release 8 or lower:
    http://compton.parish.hants.gov.uk/about/this-website/browser-type/

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Hidefrom Opera doesn't work’ is closed to new replies.