在FIREFOX中访问隐藏变量时出现问题 [英] Problem accessing hidden variable in FIREFOX

查看:69
本文介绍了在FIREFOX中访问隐藏变量时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


在一些隐藏变量中(< input type =" hidden" name =" hiddenId"

value =" test" /> ;,我存储了一些值。我使用


var id = document.getElementById(''hiddenId'')访问了值test;


它在IE中工作正常。但是在Mozilla Firefox中,null值是

返回。有没有办法使用与
$ b $兼容的隐藏变量b浏览器......?


我不知道javascript中的浏览器兼容性。任何人都可以帮助我

解决这个问题.. .......


谢谢,

karthik

Hello all,

In some hidden variable (<input type="hidden" name="hiddenId"
value="test" /> ,i stored some value.I accessed the value "test" using

var id = document.getElementById( ''hiddenId'' );

It is working fine in IE. But in Mozilla Firefox , null value is
returned.Is there any way to use hidden variables compatible to
browsers......?

I don''t know browser compatibility in javascript.Can anyone help me to
tackle this problem.........

Thanks,
karthik

推荐答案

k.*********@gmail.com 说以下是1/13/2006 2:43 AM:
k.*********@gmail.com said the following on 1/13/2006 2:43 AM:
大家好,

在一些隐藏变量中(< input type =" hidden" name =" hiddenId" ;
value =" test" />,我存储了一些值。我访问了值test。使用


这不是一个隐藏的变量,它是一个隐藏的输入。

var id = document.getElementById(''hiddenId'');


如果输入没有ID,Firefox应该如何通过ID找到它? IE

根据NAME属性错误地抓取它。

它在IE中工作正常。但是在Mozilla Firefox中,null值被返回。有没有办法使用与浏览器兼容的隐藏变量......?

我不知道javascript中的浏览器兼容性。任何人都可以帮我解决这个问题.........
Hello all,

In some hidden variable (<input type="hidden" name="hiddenId"
value="test" /> ,i stored some value.I accessed the value "test" using
Thats not a hidden variable, its a hidden input.
var id = document.getElementById( ''hiddenId'' );
How is Firefox supposed to find it by ID when the input has no ID? IE
incorrectly grabs it based on the NAME attribute.
It is working fine in IE. But in Mozilla Firefox , null value is
returned.Is there any way to use hidden variables compatible to
browsers......?

I don''t know browser compatibility in javascript.Can anyone help me to
tackle this problem.........




给你的输入一个ID,改变到document.forms集合:


document.forms [''formNAMEnotID'']。elements [''elementNAMEnotID'']。value;


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /



Either give your input an ID, change to the document.forms collection:

document.forms[''formNAMEnotID''].elements[''elementNAMEnotID''].value;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


k。 *********@gmail.com 写道:
大家好,

在一些隐藏变量中(< input type ="隐藏" name =" hiddenId"
value =" test" /> ;,我存储了一些值。我使用

var id = document.getElementById访问了值test (''hiddenId'');

它在IE中工作正常。


IE错误地实现了getElementById:


" getElementById:返回其ID由elementId给出的元素。如果

不存在这样的元素,则返回null。DOM 2 Core getElementById
http ://www.w3.org/TR/DOM-Level-2-Cor...ml#ID-getElBId 和DOM 3

核心getElementById
http://www.w3.org /TR/DOM-Level-3-Cor...ml#ID-getElBId

getElementsByName:使用[HTML 4.01]文档,此方法返回

(可能为空)元素的集合,其名称值由

elementName给出。 DOM 2 HTML getElementsByName

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259

但是在Mozilla中Firefox,返回null值。


每个DOM 2核心哪个是正确的。


有没有办法使用与浏览器兼容的隐藏变量......?
Hello all,

In some hidden variable (<input type="hidden" name="hiddenId"
value="test" /> ,i stored some value.I accessed the value "test" using

var id = document.getElementById( ''hiddenId'' );

It is working fine in IE.
IE incorrectly implements getElementById :

"getElementById: Returns the Element whose ID is given by elementId. If
no such element exists, returns null." DOM 2 Core getElementById
http://www.w3.org/TR/DOM-Level-2-Cor...ml#ID-getElBId and DOM 3
Core getElementById
http://www.w3.org/TR/DOM-Level-3-Cor...ml#ID-getElBId

getElementsByName: With [HTML 4.01] documents, this method returns the
(possibly empty) collection of elements whose name value is given by
elementName. DOM 2 HTML getElementsByName
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259
But in Mozilla Firefox , null value is returned.
Which is correct per DOM 2 Core.

Is there any way to use hidden variables compatible to browsers......?




var strInputValue = document.forms [" FormName"] .inputName.value;



var strInputValue = document.forms [" FormName"]。elements [" inputName"]。value;


更多相关信息:

使用Web标准在您的网页中

使用W3C DOM访问元素

如何将特定于IE的方式转换为访问元素到W3C web

标准替换<
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom_access


对于这些类型的问题,请先检查

Mozilla Web作者常见问题

http://www.mozilla.org/docs/web-developer/faq.html


或comp.lang.javascript FAQ首先

comp.lang.javascript常见问题 - 8.1 - 2005-11-05

http://jibbering.com/faq/


Gérard

-

删除等等给我发电子邮件



var strInputValue = document.forms["FormName"].inputName.value;
or
var strInputValue = document.forms["FormName"].elements["inputName"].value;

More on this:
Using Web Standards in Your Web Pages
Accessing Elements with the W3C DOM
How to convert IE-specific ways to access elements into W3C web
standards replacements
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom_access

For these kinds of issues, check first
Mozilla Web Author FAQ
http://www.mozilla.org/docs/web-developer/faq.html

or the comp.lang.javascript FAQ first
comp.lang.javascript FAQ - 8.1 - 2005-11-05
http://jibbering.com/faq/

Gérard
--
remove blah to email me


感谢您的回复。


我使用了id隐藏变量及其工作。

现在我有另一个问题。

我有一个IFL,其onLoad事件调用javascript。在该脚本中

i使用以下内容来获取隐藏变量值(在父级中)。


var Type = aspxIFrame.parent.document.getElementById("输入);

这里的aspxIFrame是那个IFRAME的ID。


这也不适用于firefox。


错误:aspxIFrame.parent没有属性

源文件: http://192.168.1.12/_layouts/1033/SCRIPT.js

行:7

如何解决这个问题..?


谢谢,

karthik

Thanks for the reply.

I used "id" in hidden variable and its working.
Now i had another problem.
I have an IFrame whose onLoad event calls a javascript. In that script
i used the following to get the hidden variable value(in parent).

var Type = aspxIFrame.parent.document.getElementById("Type");
Here aspxIFrame is the ID of that IFRAME.

This also not working in firefox.

Error: aspxIFrame.parent has no properties
Source File: http://192.168.1.12/_layouts/1033/SCRIPT.js
Line: 7

How to solve this problem..?

Thanks,
karthik


这篇关于在FIREFOX中访问隐藏变量时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆