Js and browsers

Hello Guys ,

Any idea why the js on this page is working on FF & IE but not

chrome , safari and opera ?

http://www.wiseblocks.com/home.html

Any idea where to start to debug this or to make it work on those browsers ?

Thank you !

Hello Paul

The article says

The window.navigator.userAgent property is read-write; it has no default value.

Clearly it does have a default value since you can set the default value as explained later in the article. It also says it is read-write which suggests you can change it in javascript. If that is the case for how long is the value retained?

I’m not trying to argue the value of the useragent as a way of identifying a browser I would go for object detection everytime. But this was the method being used by the original post.

I would argue that generally people will not change the default value. I have seen references suggesting that if you identify yourself as google you can get access to restricted content.

What useragents are you using in each browser? Try setting the useragent in all the browsers to identify them all as Firefox and see if the code works then.

If so then the problem is that your code is testing a free format user enterable field for specific values where the field can actually contain anything at all.

No - it just accepts whatever is there as being correct.

If the useragent said “Eat at Joe’s” then what browser is it then - it could be any of Internet Explorer, Firefox or Safari (and possibly others).

Useragent is a free format field that is allowed to contain anything - it can’t be relied on to identify the browser.

In ICSuite-2.0.8.js you have the following code

ltb.rGr.ERV();
ltb.enabled=false;
ltb.qPc=function(){
if(ltb.rGr.rHc.osK=="Mac"&&ltb.rGr.rHc=="Firefox")
ltb.enabled=true;
else if(ltb.rGr.rHc=="Firefox" )
ltb.enabled=true;
else if(ltb.rGr.rHc=="Explorer"
&&ltb.rGr.osK=="Windows"
&&ltb.rGr.version>="5.5")
ltb.enabled=true;
else if(ltb.rGr.rHc=="Mozilla"
&&ltb.rGr.osK=="Windows"
&&ltb.rGr.version>="1.7")
ltb.enabled=true;
else if(ltb.rGr.rHc=="Netscape"
&&ltb.rGr.osK=="Windows"
&&ltb.rGr.version>="8.1")
ltb.enabled=true;
else
ICOpen.Log.info(ltb.rGr.rHc+" "+ltb.rGr.version+" "+ltb.rGr.osK)
};
ltb.qPc();

ltb.enabled is coming out as false. If you force it to true then everything (to my eye) looks OK.

Chrome is partially matching on

else if(ltb.rGr.rHc=="Mozilla"
&&ltb.rGr.osK=="Windows"
&&ltb.rGr.version>="1.7")

but the version is null so that part of the condition is not matching

ltb.rGr.version is set by the function ltb.rGr.ERV() which works from an array dataBrowser.

Haven’t gone any deeper.

Hope that helps.

Are you the developer for wiseblocks or simply as user?

Has the utility ever worked with Chrome/Safari/Opera?

The Chrome and Safari rendering engine are very similar. So if you are having problems with one it is likely you will have problems with the other. But Opera is a different beast.

Obviously, you are talking about quite a complicated bit of code - a lot in compressed form so difficult to debug.

I would initially suspect that the code that should be executed when the page has loaded is not being executed.

What are your own thoughts?

The default value is whatever value the person who sets up the browser on the computer sets it to.

Internet Explorer stores its useragent in the registry and so anyone can change the value there if they know how to update the registry.

Firefox has the useragent listed with all the other config settings if you open the advanced config and you can change it to anything you like there.

Safari provide a menu for selecting between common useragents such as those that IE and Firefox usually start with and the last option there is an input field to enter whatever useragent you like.

Opera only gives a choice of several standard useragents but can automatically switch between them as you go from site to site either through you telling it to use a specific useragent for a specific site or through Opera itself having specific useragents preconfigured for specific popular sites.

I haven’t heard of anyone updating the useragent from JavaScript. If you did then it would only be the copy of the field value being used within the current web page and it would be reloaded the next time you load a page into the browser.

Useragent is a free format field that is allowed to contain anything - it can’t be relied on to identify the browser.

You seem to be saying that anybody can alter how there browser identifies themselves via the useragent. If so how?

I know a lot of web crawlers identify themselves in particular ways and so server side applications can not utilise this information but I was of the impression that if you when to any Chrome browser (of a particular version number) then the useragent property would be the same.

comments ? :slight_smile:

The following should help to explain how.

https://developer.mozilla.org/en/navigator.userAgent

Came across this javascript code for detecting the browser.

http://www.quirksmode.org/js/detect.html

Very similar :wink: to what you are trying to do. It will correctly interpret the browser, version and os from the useragent but you will still need to change ltb.qPc to accept it.