Re: Best way to deal with Javascript (in)compatibility using PHP?



christian9997@xxxxxxxxxxx wrote:

> Hi
>
> We have started off using a $_GET parameter to keep track of the user's
> browser:
>
> We detect what browser the visitor is using when he first arrives on
> our website then we do a redirect to the same page adding on
> "&browser=IE" or "&browser=DOM" at the end of the url (and we keep the
> browser parameter in the URL the whole time he is on the website), this
> enables us to use the following PHP method:
>
> function javascript($name) {
> if($_GET[brow] == "IE") {
> return "document.all('$name')";
> }
> else {
> return "document.getElementById('$name')";
> }
> }
>

If find that putting this function into your javascript library solves the
problem:

function ob(oname) {
if (document.getElementById)
return document.getElementById(oname);
else if (document.all)
return document.all[name];
}


Once this is in there, you can write universal code that just refers to
objects using the "ob('id')" function. Note that it is going by ID, not by
name.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
.



Relevant Pages

  • Re: Slow Downloads
    ... The link I provided was for Broadband Reports, not Cox. ... comfortable switching from IE to another browser. ... Are there any Web sites that cause no problems at all? ... America's website takes a long time to load. ...
    (microsoft.public.windowsxp.general)
  • Re: single page apps, URL hash setting, bookmarking, & the back button.
    ... illusion for users with no expectations to begin with. ... Incompetence and broken browser behavior were definite factors (with ... links because they find the website hard to use, ...
    (comp.lang.javascript)
  • Re: Highjacked homepage
    ... This may be caused by spyware/malware that's gotten installed on ... Windows Defender and/or Spybot Search & Destroy ... section, uncheck "Enable third-party browser extensions", click Apply, click ... website, while the website of choice is unobtainable also this website has ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: NXP Gone mad
    ... responsible for the development of the new NXP site. ... displayed in a new window. ... - the NXP web site is particuarly Browser ... In one browser on visting the website after the SECOND invitation to the ...
    (comp.arch.embedded)
  • Re: Im sure I shall regret this.............
    ... set up a local website. ... I see a square in the middle of the browser, ... suggest this is one of the things a Tourist Info office might be for. ... Well, okay, I'm a nitpicking perfectionist. ...
    (uk.rec.sheds)