How to detect browser addons in Firefox, Opera and IE? - php

How to - using either JavaScript or PHP - detect addons that are used by a user? In particular the ORBIT addon.

I realize this is an old question but it popped up on a google search for me. It most definitely is possible to detect browser addons. Here are a couple of resources to check out:
http://ha.ckers.org/blog/20060823/detecting-firefox-extentions/
http://webdevwonders.com/detecting-firefox-add-ons/

In general, you can't.
Some addons (eg, Firebug) expose a client-side object model to the page, in which case you can detect them using Javascript.

Related

So the user agent can be faked.. Ok... is there a valid reason why I shouldn't use php to detect the browser?

I have never understood why some people say making custom css for each browser is a bad thing. To keep my page size down and download times fast it makes perfect sense to me to make a custom css for the major browsers (especially IE in its many different forms), and a general catch all css for everything else.
If you want to send out a bloated, huge, Swiss army knife of the css world, for all situations then go right ahead I'm not going to stop you.
Fast detection of the browser is important when doing this. Loading a JavaScript file to detect the browser seems slow. So I would prefer to use php to detect the browser, and send out the specified css. Or at least a general browser specific css then use the JavaScript to load a more detailed version of the css.
But I've read article after article about why this is a bad thing. The main reason behind each of these articles is because the user agent can be faked. Or there using Firefox but the server thinks they're using IE7 so it sends out the wrong css file.
As a developer/designer of web apps why is this my problem? If you want to use Firefox, but tell my server your using safari or IE*, and get a crappy looking page, why is it my problem?
And don't throw that whole if the user can't see your site right they'll never come back, or some kind of similar argument at me. a normal user isn't going to be doing this. its only going to be the people who know how to do this, and will know whats wrong when my site looks crappy.
This is similar to looking at my site on a old Apple II (I have no clue how), and yelling at me because everything looks green.
So is there a good reason, not a personal preference, why I shouldn't use php to detect the browser and send out customized css files?
I do this mostly for the different versions of IE. It just seems like for some sites, adding the if IE6 and if IE7 parts just double or triple the size of the css file.
Typically when a user intentionally fakes the user agent string, it is because something is not viewable in the user's browser that should be. For example, some sites may restrict users to IE or Firefox, but the user is using Iceweasel on Debian. Iceweasel is just a Firefox renamed for trademarked reasons (there are a few other changes also), so there is no reason that the site should not work.
Realize that this happens because of (bad) browser detection, not despite it. I would say you don't need to be terribly concerned about this issue. Further, if you can just make your site reasonably cross-browser compatible, it won't matter at all. If you really want to use browser-specific CSS, and you don't want to do so all in one CSS file, don't let a fake user agent stop you.
As long as the only thing you're doing is changing style sheets, there is no valid reason as far as I can tell. If you're attempting to deliver custom security measures by browser, then you'll have issues.
Not sure about php but in Rails it is normal and dead simple practice to provide css files and different layouts based on the user agent particularly when considering that your site is just as likely to be accessed by any of the myriad of available mobile devices, never mind writing for the most popular (Currently Firefox) browsers and even writing custom MIME types if need be is also dead simple.
IMO not doing so is pure laziness on the coders part but then not all sites are developed by professional teams of developers with styling gurus at hand. Also in languages other than Rails it might not be so simple. Sorry, I haven't a clue about PHP so this may not be an appropriate reply
In my opinion, starting with normalize.css, and having a base style sheet to start, overriding the base styles as needed usually works along with making sure you set appropriate fallbacks. If you really need it a few media queries, and feature detection can go a long way.
One reason you shouldn't base things off of the browser is because major search engines like Google and Yahoo prohibit displaying different content for different browsers. GoogleBot can detect different CSS and HTML and you may get bad search positioning. Additionally, if you use any advertising services you may be in breach of their contract by displaying varying content.

Make a JavaScript-aware Crawler

I want to make a script that's crawling a website and it should return the locations of all the banners showed on that page.
The locations of banners are most of the time from known domains. But banners are not in the HTML as an easy image or swf-file. Most of the times a Javascript is used to show the banner.
So if a .swf-file or image-file is loaded from a banner-domain, it should return that url.
Is that possible to do? And how could I do that roughly?
Best would be if it can also returns the landing page of that ad. How to solve that?
You could use selenium to open the pages in a real browser and then access the DOM.
PhantomJS might also be worth a look - it's a headless version of WebKit (the engine behind Chrome, Safari, etc.).
However, none of those solutions are pure php - if that's a requirement, you'll probably have to write your own JavaScript engine in PHP (which is nothing I'd ask my worst enemy to do ;))
In order to get the output of the JavaScript you will need a JavaScript engine (such as Google's V8 Engine). The V8 engine is written in C++ but there are some resources that tell you embed the V8 engine into PHP.
With that said, you have to study the output "by hand" and determine exactly what can be scraped and how to identify it. Once you've identified some common syntax for the advertisement banners, then you can write a script to extract the banner and the landing page which is referenced.
None of this is easy work, but if you have an example of an ad you'd like to collect then I can give you more advice.

if browser CSS3

How do we check to see if the browser browsing a webpage is CSS3 capable. I know how to check for which browser is coming in using PHP but how do we check specifically that the browser supports CSS3.
Any ideas,
Marvellous
PHP (and I imagine any other server-side technology) has no idea about a browser's CSS capabilities. However on the client side, you can use Modernizr and handle rendering of your page based on the guides it gives you about what CSS3 properties a browser supports.
No browser supports all of CSS 3. Many browsers support bits of CSS 3.
You can detect some CSS 3 features with Modernizr, but that uses client side scripting.
CSS3 is not 'one' feature that you can detect. Browsers implement parts of it one after another. So, for example, IE 9 implements parts of CSS3 like box-shadow, but does not support some other things.
What you could do is make a list of browsers that support a given CSS3 feature and test the user agent. If you do this, http://caniuse.com/ may be a good help.
But I dont recommend this. The best way to check certain features will be client-side, for example with Modernizr.
Edit: If you need to provide a fallback, do it client-side too. Modernizr optionally includes a library named yepnope, with which you can easily load files if the browser doesnt support something. This could look like this:
yepnope({
test : Modernizr.csstransitions,
nope : ['jquery.js', 'transitions-fallback.js']
});
This code snippet would test for csstransitions and if they are not available, it would load jQuery and the transitions fallback js file.
You can't do a blanket check because of the patchy support of CSS3 and the variances between browsers. See here: How to check a certain CSS capability in a browser using JavaScript?
I'd recommend you to use Modernzir - http://www.modernizr.com/
There is some web tools that can check how your browser is css3 compatible:
Selector test
Acid3
Modernizr
And there is a lot more...
Using PHP's get_browser function you can do
$cssversion = get_browser(null, true)['cssversion'];
This will tell you the highest version the browser supports but as others have stated browser do not support every attribute within a version.

Is there any application for checking 'what's loading onto the website right now' kindof?

I am developing a website and sometimes the browsers keeps loading, and I would like to know exactly what's making it load for so long. It gets stuck kindof.
So I wonder if there is any application or way to check what is getting loaded onto the page, so I can see what element or object it gets stuck on?
The website uses php/javascript/mysql and html
FireBug allows you to see that other than other great options
Firebug is a nice add-on for Firefox. It will tell you that, and much more
Firefox + firebug. In the net tab you can see which resources are loading.
I recommend Fiddler for this type of thing. You can view a timeline of all elements loading on the page.
http://www.fiddlertool.com/
Besides Firebug/Firefox, also look into the Developer tools in Chrome. The latest addition is the Chrome Speed Tracer extension, which lets you see exactly what loads are taking how much time, and all kinds of other stuff.

Javascript not working on Blackberry

Have a script that using jquery validation. Tested on 2 Blackberry's and neither worked properly.
http://andrewpeller.com/contest/indexTest.html
1st one - Blackberry Bold
Email validation would not work even with valid email such as test#hotmail.com
2nd one
Form would not submit at all.
Any suggestions as to how to get this to work? Will jquery even work on the blackberry?
thanks
You will probably need to accommodate users with JavaScript turned off when aiming at mobile devices.
Your form seems to be designed so that it can't be submitted without Javascript turned on. You would have to change this to make it work on non-JS browsers. Make sure you have some kind of server side validation for the fields.
The default Blackberry browser is very limited in JavaScript. I would not expect jQuery to work well in its default browser.
However, I suggest to try using Opera Mini for the Blackberry. It handles JavaScript much better. I managed to run a few web applications using ExtJS 2.x (jQuery adapter) in Opera Mini on various Blackberry models, without problems.
If you are going to deploy this web page to the public, I suggest using plain XHTML/CSS and do server-side form validation.
I don't know what BlackBerry you have but besides Opera Mini you should also look at the new Bolt Browser it is really nice.
Now with that being said. As a mobile developer for many, many years I always encourage developers and clients to develop their mobile sites without the requirement for JS, whenever possible.
Double check your BlackBerry browser options - some devices have Javascript turned off by default.
Bolt browser is not supported now. Actually jQuery validation works on bb5 but breaks onfocus, onblur events. On bb6 it works fine.

Categories