Netscape 4.x兼容性问题

编程入门 行业动态 更新时间:2024-10-26 12:23:01
本文介绍了Netscape 4.x兼容性问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用以下行的函数: var level = document.getElementById(id); 我也知道我要找的元素的名称。在Netscape Communicator 4.7中,然而,这不起作用......我该怎么做才能在这个浏览器中获得相同的元素?谢谢! Jon

Hi, I have a function that uses the following line: var level = document.getElementById( id); I also know the name of the element I am looking for. In Netscape Communicator 4.7, however, this doesn''t work... What can I do to get the same element in this browser? Thanks! Jon

推荐答案

Jon写道: var level = document.getElementById(id); 我也知道我要找的元素的名称。然而,在Netscape Communicator 4.7中,这不起作用......我该怎么做才能在这个浏览器中获得相同的元素?谢谢! var level = document.getElementById( id); I also know the name of the element I am looking for. In Netscape Communicator 4.7, however, this doesn''t work... What can I do to get the same element in this browser? Thanks!

由于netscape 4.x不支持getElementById(),它变得复杂。 你是什么类型的元素试图获得这个位置? 我写了这个小型库以获得< a>的位置 Netscape4.x支持的元素。它并不总是很漂亮,但是如果你可以在某处放置一个< a> 标签并将其用作参考,它允许定位对象 相对于< a>在netscape4: www.javascripttoolbox/anchorposition/ - Matt Kruse Javascript工具箱: www.JavascriptToolbox/

Jon写道: Jon wrote: 我有一个使用以下行的函数: var level = document.getElementById(id); 我也知道我要找的元素的名称。然而,在Netscape Communicator 4.7中,这不起作用......我该怎么做才能在这个浏览器中获得相同的元素?谢谢! Jon Hi, I have a function that uses the following line: var level = document.getElementById( id); I also know the name of the element I am looking for. In Netscape Communicator 4.7, however, this doesn''t work... What can I do to get the same element in this browser? Thanks! Jon

Jon, Netscape 4(以及大多数其他旧版浏览器)不支持 使用getElementById()或者,事实上,现代的其他大部分都是b $ b DOM。 向后兼容是指向后兼容。当然,东西很好,但不是新的东西。 所以,简而言之,你需要问问自己你想要多少钱 支持这些旧版浏览器。值得努力吗?要求您的用户升级到现代浏览器会更容易吗??该问题影响了多少用户?b $ b?如果你发现你确实需要支持这些旧的浏览器,那么肯定可以使用旧版本的 代码来执行相同或相似的操作 - 但对于显而易见的原因 这意味着您将难以维护代码并且需要测试软件。

Jon, Netscape 4 (along with most other older browsers) does not support the use of "getElementById()" or, in fact, most of the rest of the modern DOM either. The "backward-compatible" stuff, of course, is fine but not the newer stuff. So, in a nutshell, you need to ask yourself just how much you want to support these older browsers. Is it worth the effort? Would it be easier to ask your users to upgrade to modern browsers? How many users are affected by the problem? If you find you really do need to support these older browsers then it is certainly possible to use older versions of code that will do the same or similar things - but for obvious reasons that means you will have a much harder time maintaining the code and testing the software.

2004年6月15日07:27:08 -0700,Jon< jm ***** @ jonathanludwig>写道: On 15 Jun 2004 07:27:08 -0700, Jon <jm*****@jonathanludwig> wrote: 我有一个使用以下行的函数: var level = document.getElementById(id ); 我也知道我要找的元素的名称。然而,在Netscape Communicator 4.7中,这不起作用......我该怎么做才能在这个浏览器中获得相同的元素?谢谢! Jon Hi, I have a function that uses the following line: var level = document.getElementById( id); I also know the name of the element I am looking for. In Netscape Communicator 4.7, however, this doesn''t work... What can I do to get the same element in this browser? Thanks! Jon

你好Jon, 马特和马克都发表了好主意。 以下内容来自X图书馆,获得LGPL许可( cross-browser/)。你不必使用图书馆,但这应该给你一些想法。 函数xGetElementById(e) { if(typeof(e)!=''string'')return e; if(document.getElementById)e = document.getElementById(e); 否则if(document.all)e = document.all [e]; else if(document.layers)e = xLayer(e); else e = null; 返回e; } 函数xLayer(id,root) { var i,layer,found = null; if(!root)root = window; for(i = 0; i< root.document。 layers.length; i ++){ layer = root.document.layers [i]; if(layer.id == id)return layer; if(layer.document.layers.length)found = xLayer(id,layer); if(found)return found; } 返回null; }

Hi Jon, Matt and Mark have both posted good ideas. The following is from the X Library, licensed LGPL (cross-browser/). You don''t have to use the library, but this should give you some ideas. function xGetElementById(e) { if(typeof(e)!=''string'') return e; if(document.getElementById) e=document.getElementById(e); else if(document.all) e=document.all[e]; else if(document.layers) e=xLayer(e); else e=null; return e; } function xLayer(id,root) { var i,layer,found=null; if (!root) root=window; for(i=0; i<root.document.layers.length; i++) { layer=root.document.layers[i]; if(layer.id==id) return layer; if(layer.document.layers.length) found=xLayer(id,layer); if(found) return found; } return null; }

更多推荐

Netscape 4.x兼容性问题

本文发布于:2023-11-17 17:11:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1610414.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:兼容性问题   Netscape

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!