I would like to have a javasript/jscript function template/"framwork"
instead of checking browsers by name. The shortness of script in my opinion
is not the goal, but clearness and ease iof development. Could you give your
points, corrections and ideas about template below?
And are elemens ids available in form or another in all browsers or was
there some which accpets only element names? And was it that ancient
netscape only gives form elements, links, anchors and images available but
no other elements? In Finland some public organisations with lots of
machines unfortunately still have netscape 4.7.
function do_something(el em_id) // or should we other ways of referencing
too?
{
if(document.get ElementById() && e = document.getEle mentById(elem_i d))
//latest versions
{
if(e.needed_met hod()) / if(e.needed_pro perty) do_something_wi th_e
else if(e.alternativ e_method()) / if(e.alternativ e_property)
do_something_wi th_e
...
else return false;
}
elseif(document .all && e = document.all[elem_id]) // IE 5.5
{ do_something_wi th_e }
elseif( e = document.elem_i d) // Netscape 4.x
{ do_something_wi th_e_or_give_up _hope }
else return false;
}
instead of checking browsers by name. The shortness of script in my opinion
is not the goal, but clearness and ease iof development. Could you give your
points, corrections and ideas about template below?
And are elemens ids available in form or another in all browsers or was
there some which accpets only element names? And was it that ancient
netscape only gives form elements, links, anchors and images available but
no other elements? In Finland some public organisations with lots of
machines unfortunately still have netscape 4.7.
function do_something(el em_id) // or should we other ways of referencing
too?
{
if(document.get ElementById() && e = document.getEle mentById(elem_i d))
//latest versions
{
if(e.needed_met hod()) / if(e.needed_pro perty) do_something_wi th_e
else if(e.alternativ e_method()) / if(e.alternativ e_property)
do_something_wi th_e
...
else return false;
}
elseif(document .all && e = document.all[elem_id]) // IE 5.5
{ do_something_wi th_e }
elseif( e = document.elem_i d) // Netscape 4.x
{ do_something_wi th_e_or_give_up _hope }
else return false;
}
Comment