Re: Best way to deal with Javascript (in)compatibility using PHP?
- From: Kenneth Downs <knode.wants.this@xxxxxxxxxxxx>
- Date: Wed, 29 Jun 2005 11:15:07 -0400
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)
.
- References:
- Best way to deal with Javascript (in)compatibility using PHP?
- From: christian9997
- Best way to deal with Javascript (in)compatibility using PHP?
- Prev by Date: Re: use a javascript variable in php?
- Next by Date: Re: Call for LAMP Standardization -- Installations/User-Group Admin
- Previous by thread: Re: Best way to deal with Javascript (in)compatibility using PHP?
- Next by thread: Re: Best way to deal with Javascript (in)compatibility using PHP?
- Index(es):
Relevant Pages
|