bit-labs

bit-labs does not currently provide support for this item.

14 comments found.

demo isnt working

Please, check it now. There was fixed a bug with Safari browsers. Best regards.

Doesn’t work on ipad2 with default Safari browser or Mercury browser (app). Reports both as being desktop despite turning ipad. Doesn’t detect mobile safari as any browser (didn’t highlight any browser in demo).

Seems broken when it comes down to actually working on the devices you’re trying to detect. The demo worked fine when adjust my PCs browser window, but that’s it.

Thank you for contacting me.

I realize that there was one-symbol bug with Safari browser. I have fixed it and upload for a moderation. Demo is also updated. Thank you for letting me know.

The code doesn’t seem to be working for Android devices. Like the other user said, it stays in desktop mode when on my tablet or phone. The output on android with chrome browser and stock browser shows up as following: You are using undefined vundefined on Linux! Screen Mode: desktop.

Any ideas?

Hi bkress,

Thank you for your report. I realize that the width of the window was incorrectly detected in some mobile devices. I edited the function that does it so now it should work more stable.

I uploaded the new version of the script and it will be available on CodeCanyon in 1-3 days.

As for the Chrome Mobile and Stock browsers, the CSS/JS Browser Determiner can only detect Android device (for CSS use only, like .android { ... }) but not the name of mobile browser. And you’re not able to detect Android devices using script’s API, but only whether is mobile device or not. If you need to detect Android browser, you can use native JavaScript e.g. if (/Android/.test(navigator.userAgent)) { ... }

Please, let me know if you will find some other issues.

Thank you!

Hi,

Is it compatible with JQuery?

I would like to use your script with a condition on a JQuery code.

Thanks!

Mick

Hi, Mick.

Yes, it is based on native JS and has only one variable “browser”, it is an object with all the stuff, so it can be used with any other library

Best regards

Thanks! 5/5

How can I apply a condition to a Style in the document?

<style type="text/css"> if (!browser.is_desktop) { .content { display: hidden } } </style>

Thanks!

Mick

Oh… Seems I have droped these 3 properties (which detected screen resolution) from 2-nd version. I’m sorry for that. they shouldn’t be displayed on documentation page.

So there is no such property (is_desktop) in a browser object. You need to use
if (browser.mode == "desktop") { ... } 
And it will work then

Thanks

Has removed them from the documentation

Thanks! :)

Hi,

What it is the best formula to apply a condition to detect the Responsive mode?

On !browser.is_desktop or browser.width() < 480 ?

Thanks again!

Mick

Hi, Mick

Please use browser.mode instead of browser.is_desktop . Like
if (browser.mode != "desktop) { ... }
You ofcourse you can also use browser.width()

It doesn’t work for IE9 64bit and win 7.

“browser.ie” shows Undefined

“browser.version” is correct and show 9. is_modern shows false (wrong) is_old shows true (wrong) name shows ie, correct device shows unknown

Hi, Anshuyi,

The “ie” attribute was replaced to “msie” in JavaScript API since latest update (v2.0). I just had to mention that in the description (already fixed). There was a lot of fixes and seems I forgot to mention about this one.

As for fact that the “is_modern” property returns false in IE 9 so it is not a bug. The property will only return true in case if browser supports the CSS3 transition property. So IE9 dosn’t supports this method, and now it is pretty hard to call it a modern browser.

The “device” property means the name of a mobile device like iPad, iPhone, iPod, Blackberry or Kindle. For any other devices, so it’s in most cases, it returns “unknown”.

Thank you for contacting me! Best regards

Hi,

Can this script redirect visitors to any URL we like based on the browsers?

Can this script detect mobile visitors and redirect them to another url?

Is this already inside the script or we need to customise this?

Please confirm

Hi,

Yes, of course! It has a lot of JavaScript methods using which you can easily redirect your visitors to any particular page based on user’s device or browser.

For example, if user’s browser is Firefox and it’s version less than 10 the script below will redirect user to http://mysite.com/firefox :

<script>
if (browser.firefox && browser.version < 10) {
    location.href = "http://mysite.com/firefox";
}
</script>
Put this code right after <script src="cssjs-browser-determiner.js"></script> inside of <head> section to make it faster.


Here is how to generate an URL based on the name of mobile device (only “iphone”, “ipad”, “ipod”, “blackberry”, “kindle” names are supported):

if (browser.is_mobile && browser.device != "unknown") {
    location.href = "http://mysite.com/"+browser.device;
}

Best regards

Hi,

I have a script what works very bad on IE9 will this help, to fix the issues and can i put this in the script

Hi,

Sorry for kept you waiting.

Yes, but you will need to make some changes to your code. If you know the exact place of your script where it works buggy in IE9 you can separate it with something like this:

if ( browser.ie && browser.version <= 9 ) {
    // code for IE 9 or less
} else {
    // code for other browsers
}

Of course the code above will only work with CSS/JS browser determiner installed on your site.

Best regards

Hello,

First of all, I got to say that this is a great script! really helpful for about any project that can use JS. I don’t have any complaints about it, but I do have couple of suggestions to improve this script: 1) the Variable “browser” seems to interfere with other libraries as it is a common variable name. I can be renamed to something similar, like I did ”$_browser”, or something along those lines to avoid conflicts. In my case I used the ”$” and underscore because it resembles the old jQuery ”$.browser()” function, but since it has the underscore it does not conflict with anything. 2) Since Mobiles don’t have a Firebug or liveCodeView in the browser like a regular desktop browser, it good to get the class names that will be added to the page/use. In my case I added this to the object ” $_browser._classNames = result.toLowerCase(); ” so that I can pull all the class names that will be in use ( example: alert($_browser._classNames); . Well you get the idea. 3) This line “flashEnabled: !!(navigator.mimeTypes[“application/x-shockwave-flash”] || window.ActiveXObject && new ActiveXObject(“ShockwaveFlash.ShockwaveFlash”))” conflicts with IE10, IE9 and IE8. they produce a browser security warning and it does not allow the script to Run. For now I have disabled the property by changing it to “flashEnabled: false,” as most desktop browsers support flash and now most mobiles, but it still a nice feature to have available, so if you can come up with a solution that would be awesome.

Thank you for everything, and great Job ;)

Hello, orangepixel!

I’m very glad you like it! :)

Thank you for your feedback! It is very important for me to here such opinions as yours.

I totally agree with you that variable “browser” has to have some prefixed name, or some unique name that can not be used by any other thirdparty libraries, that’s a good point. I’ve been thinking about it, but never took seriousely. Now I’m sure it has to be done! Thankfully to you ;) Please wait for the next version.

When you are on mobile device you can use documentation page for testing purposes — http://artnikpro.com/demo/cssjs-browser-determiner/ (or http://goo.gl/jJWy4C ) . There is a table that shows all the methods of “browser” object, including the value of the className propery of the head tag.

Flash detecting feature was fixed in a latest update (v2.2), please upgrade.

Thank you!

Everything, on the ‘Live Demo’ page comes back as ‘undefined’ on an iPhone 6. Does this not work on mobile devices?

Hi, sorry for long respond.

I have tested the script itself on iPhone 6 and it works OK. Probably there is some problem with demo site, I will fix it.

Thank you

Any chance this can be updated for Windows 10 and the browser Windows Edge?

Great Script that works fine! Microsoft Edge support would be nice.

Nice job :)

by
by
by
by
by
by