Rusty Horse
Rusty Horse

Reputation: 2428

How to disable the JavaScript for current page by using JavaScript

I have an unusual problem. I've made a page filled with some JS. Old browsers simply mess it up. A lot of it is included directly in the page, not in separate files and not inline.

I wonder if there is a way to generate (using PHP) some JS that would make the browser ignore all the following scripts?

Otherwise I have to make conditional inclusion of all the JS and that is something I really would like to avoid.

Thanks for any proposals.

Upvotes: 0

Views: 187

Answers (1)

Kevin Holditch
Kevin Holditch

Reputation: 5303

One way to solve this would be to detect the browser using javascript and then not running certain portions of the javascript if the browser version is one of the ones where you don't want it to run.

Another alternative (and possibly slightly easier method) would be to do the browser detection in the php code and only render out the javascript if the browser isnt one of the old one's that you want to avoid.

http://www.javascripter.net/faq/browsern.htm is a good link as to how to detect the browser in javascript.

Upvotes: 1

Related Questions