roxylandmusic has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Sorry if this is a lame question, but I just can't get around a 'browser detection' javascript on a particular website with the LWP UserAgent's agent method. This is what I used and the site does work on the browser which sets the same agent. ( Safari and Firefox on Mac ).
Here is the section of javascript that stops me from viewing the page:User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: +1.9.1.9) Gecko/20100315 Firefox/3.5.9 Content-Length: 71 Content-Type: application/x-www-form-urlencoded
Could someone please help me understand why LWP can't get around this check ?function broswerDetection(){ var appName = navigator.appName; var appVersion = navigator.appVersion; var userAgent = navigator.userAgent; var browserSupported = false; if(appName == "Netscape") { // the browser could be a Netscape o +r Firefox if(userAgent.indexOf("Firefox") == -1){ // the browser is Netscape, then we flag that the netscape + not supported browserSupported = false; } else if((userAgent.indexOf("Navigator") != -1) && (userAgent.i +ndexOf("Firefox") != -1) ){ // the broswer is Netscape v9.0 browserSupported = false; } else{ // this is actually a Firefox browser var firefoxIndex = userAgent.indexOf("Firefox") + 8; if(parseInt(userAgent.charAt(firefoxIndex)) >= 1){ browserSupported = true; } } } else if(appName == "Microsoft Internet Explorer"){ var version = 0.0; if(userAgent.indexOf("Opera") == -1){ // Microsoft Internet Explorer if(appVersion.indexOf("MSIE") != -1){ var temp = appVersion.split("MSIE"); version = parseFloat(temp[1]); } if(version >= 6.0){ browserSupported = true; } } else{ // Opera broswer, flag the broswer not supported browserSupported = false; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP UserAgent's agent method and browser check
by Corion (Patriarch) on Nov 10, 2010 at 12:58 UTC | |
|
Re: LWP UserAgent's agent method and browser check
by marto (Cardinal) on Nov 10, 2010 at 13:01 UTC | |
by Anonymous Monk on Nov 11, 2010 at 00:13 UTC |