Geeks With Blogs

News



Add to Google

Tim Hibbard CEO for EnGraph software

The messaging feature of Where's Tim was not working in FireFox and Safari.

I changed my javascript code from:

var msg = document.getElementById(”txtMessage”).getAttribute(”value”);
var frm = document.getElementById(”txtFrom”).getAttribute(”value”);

To:

var msg = document.getElementById(”txtMessage”).value;
var frm = document.getElementById(”txtFrom”).value;

That seemed to be the fix for Firefox.  I admire you web developers, this is much less intuitive than fat client development :)

Posted on Saturday, December 3, 2005 1:16 PM Where's Tim | Back to top


Comments on this post: document.getElementById(id).getAttribute("value") on FireFox

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
Thanks a lot for this tip..saved me a lot of headache... :D
Left by Carlton on Nov 20, 2006 11:28 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
Hello,

I had similar problem when working with ajax and used following to resolve the issue:

var msg=document.getElementNodeById(”message”);
var frm=document.getElementNodeById(”from”);

Also make sure to remove any spaces between variable and dom object
Left by itHighway.co.uk on Apr 05, 2007 10:33 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
I m developing an ASP.NET 2.0 Website, in which i have a Panel and i want to give its height through javascript.
the code that i have written is working fine in IE but in FireFox the code is not working. Actually the function document.getElementId is not working

i have an ASP.NET panel by id 'pan1 '

i have written the following code

document.getElementById('<%=pan1.ClientID%>').height = 300;


the above code is working fine in IE but not in FireFox
Can u plz help me out .
Left by Vibhore Benjamin on May 18, 2007 4:43 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
you are missing the style attribute..

document.getElementById('<%=pan1.ClientID%>').style.height = 300;
Left by Nahum Silva on May 21, 2007 6:10 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
also the "300px" or '300px'
Left by nahum silva on May 21, 2007 6:11 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
I am having trouble with the getElementById in firefox. I am trying to grab all the form objects so i can run through and validate it.

Currently, I have:
var formObj = document.getElementById(formname);

It works great in IE, but on FF it craps out. I have tried this several different ways, but i refuses to grab all of the form elements.
Left by Lee on May 31, 2007 12:08 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
you need to set the id attribute of the form tag to be [formname]

<form name="formname" id="formname"...

IE picks up on 'name' which is where the confusion lies...
Left by rootnode on Jun 12, 2007 3:06 AM

# Loop in javascript not working in FF
Requesting Gravatar...
The below code is not working in FF but works fine in IE

if(document.getElementById("approve" + icount).checked){
.....
......
}
Any Inputs?
Left by Hari on Jul 19, 2007 4:45 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
Hi all
following code is run in IE but not in firefox

var fileUpload = document.getElementById("<%=FileUpload1.ClientID %>");
fileUpload.click();

help please
Left by Yunus on Aug 14, 2007 9:21 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
this code working on IE but not in Firefox, best regars for help.

<script language="javascript" type="text/javascript">
function strValue()
{ document.getElementById("input_1").value=document.getElementById("select_1").options[document.getElementById("select_1").selectedIndex].text;
}
Left by POPO on Nov 27, 2007 8:12 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
code works with IE not FF

var a=new Array();a['United States']=new Array('Alabama','Alaska','American Somoa','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Florida','Guam','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','New Hampshire','Nevada','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming');function setStates(){
cntrySel=document.getElementById('country');
stateList=a[cntrySel.value];
changeSelect('born_state',stateList,stateList);
changeSelect('state',stateList,stateList);
changeSelect('shipstate',stateList,stateList);}
function changeSelect(fieldID,newOptions,newValues){
selectField=document.getElementById(fieldID);
selectField.options.length=0;for(i=0;i<newOptions.length;i++)
{selectField.options[selectField.length]=new Option(newOptions[i],newValues[i]);}}


function addLoadEvent(func){var b=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){if(oldonload){b();}
func();}}}
addLoadEvent(function(){setStates();});
Left by Terry on Feb 02, 2008 10:40 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
this script works in IE but not in Firefox or Safari... not my script but a site that i'm using... want to send to the administrator.

window.history.forward(1);
function chk(cb){
var ck = false;
var ck1 = false;
var ck2 = false;
var ck3 = false;
var ck4 = false;
var ck5 = false;
var ck6 = false;

if (document.getElementById('c1').checked == true) {
ck1 = true;
}
if (document.getElementById('c2').checked == true) {
ck2 = true;
}
if (document.getElementById('c3').checked == true) {
ck3 = true;
}
if (document.getElementById('c4').checked == true) {
ck4 = true;
}
if (document.getElementById('c5').checked == true) {
ck5 = true;
}
if (document.getElementById('c6').checked == true) {
ck6 = true;
}
if(ck1 == true && ck2 == true && ck3 == true && ck4 == true && ck5 == true && ck6 == true){
ck = true }

if (ck == true) {
document.getElementById('mybutton').disabled = false;
}
else {
document.getElementById('mybutton').disabled = true;
}


}
//-->
Left by doctorSpoc on Mar 05, 2008 11:36 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
This doees not work on firefox:

document.getElementById("state").disabled=true;

Do any of you know how to fix this?
I'm trying to use it in this function, it works on
IE not on firefox

function change()
{
if (document.getElementById("country").value == "USA")
{
document.getElementById("state").disabled=false;
document.getElementById("state").value=""
}
else
{
document.getElementById("state").disabled=true;
document.getElementById("state").value=" ";
}

}
Left by g04tee on Apr 30, 2008 2:19 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
i want to disable the hyper link
i am using the code
document.getElementById(id).disable=true
its working fine in ie but its not working in firefox
how can i do it
plz hlep me
Left by satish on Jul 22, 2008 11:54 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
i have the same problem in Firefox: I seems that yopu cannot get a reference to objects except a form: so use this to set a value of an elelment:
document.getElementById("form1").elementname.value

or the style:
document.getElementById("form1").style.visibility = "visible";
Left by Mike Boland on Sep 23, 2008 9:21 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
thx thx thx
Left by Chris on Dec 26, 2008 1:49 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
@venkatesh
I resolved that with xajax (php library)
cheers!
Left by ptx on Jan 20, 2009 1:52 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
this script works in IE but not in Firefox . In Firefox, function Back is available but function Next not. Help me, please!

<script language="javascript">
var arrIMG = new Array();
var index=0;
var dx=document.getElementById('content');
next=function (){
if (index==arrIMG.length-1) {
alert(" click Back !");
}
else {
index++;
dx.innerHTML="<IMG src='imageview.aspx?width=&proid="+arrIMG[index]+"' ismap=true>";
resizewin();
}

}

back=function (){
if (index==0) {
alert(" click Next ");
}
else {
index--;
dx.innerHTML="<IMG src='imageview.aspx?width=&proid="+arrIMG[index]+"' ismap=true>";
resizewin();
}

}
resizewin=function() {
var iX=0;iY=0;
var maxX=0;
var maxY=0;
for( i=0;i<document.images.length;i++) {
img=document.images[i];
if (img.offsetWidth>maxX) maxX = img.offsetWidth;
if (img.offsetHeight>maxY) maxY = img.offsetHeight;
}
if (maxX>500) iX = maxX; else iX = 500;
if (maxY>400) iY = maxY; else iY = 400;
window.resizeTo(iX+50,iY+80);
}
browsername=navigator.appName;
if (browsername.indexOf("Microsoft")!=-1)
{
var d = new Date();
var s = d.getMilliseconds().toString()+d.getSeconds().toString()+d.getMinutes().toString()+d.getHours().toString()+d.getDay().toString()+d.getMonth().toString()+d.getFullYear().toString();
var x=window.location.search; x=x.substring(1);
var xx=x.split('=');
var val=xx[1];
arrIMG = val.split(',');
if (arrIMG.length>=0) {
dx.innerHTML="<IMG src='imageview.aspx?width=&proid="+arrIMG[index]+"' ismap=true>";
}
resizewin();
}
else
{
var d = new Date();
var s = d.getMilliseconds().toString()+d.getSeconds().toString()+d.getMinutes().toString()+d.getHours().toString()+d.getDay().toString()+d.getMonth().toString()+d.getFullYear().toString();
var x=location.search; x=x.substring(1);
var xx=x.split('=');
var val=xx[1];
arrIMG = val.split(',');
if (arrIMG.length>=0) {
dx.innerHTML="<IMG src='imageview.aspx?width=&proid="+arrIMG[index]+"' ismap=true>";
}
resizewin();

}

</script>


Left by tuanmetal3002 on Mar 29, 2009 10:17 PM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
very thank you
Left by mohammad on Apr 13, 2009 7:06 AM

# var YAS_yer = document.getElementById(layerName); is not working in FF
Requesting Gravatar...
Hi there,

Could anyone please help me what is the format of document.getElementByID in FF.

Because it works in all browser and i have a problem in FF. when i check with alert funtion - it give 0 value.

var YAS_yer = document.getElementById(layerName);


Thanks in advance
Left by bala on Jun 02, 2009 8:31 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
@bala, try this :

var YAS_yer = document.getElementById(layerName).value;
Left by 4bonajm on Jul 14, 2009 4:35 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
I am trying to get this working but just cant. Don't know if this is dead or not but i thought i would shove it in here... :)

This works in IE not FF... :(

function expandCreative(d) {
document.getElementById(d).style.height = "180px"; // expanded height
}
function collapseCreative(d) {
document.getElementById(d).style.height = "40px"; // normal height
}
Left by total.bs on Sep 01, 2009 6:18 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
sorry guys - it does work i fixed the height in the CSS :-$ sorry.
Left by total.bs on Sep 01, 2009 6:23 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
To add or modify attributes of an element, you should now use the DOM methods for this, which are:

getAttribute(attributeName)

removeAttribute(attributename)

setAttribute(attributename, value)

For example:
<img id="myimage" src="dog.gif" />

<script type="text/javascript">
var imgsrc=document.getElementById("myimage").getAttribute("src")
document.getElementById("myimage").setAttribute("src", "cat.gif")
</script>
Left by Andrew on Oct 04, 2009 5:34 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
Here is a solution of my problem.

Written in ASP.NET / C#.
I needed to call click() method of a special button when Enter is pressed on TextBox focused.

I had such code:

// "Search button click" when hitting enter on SearchTextBox
string sSearchButtonClientId = SearchImageButton.ClientID;
string sCommand = @"if (event.which || event.keyCode)
{
if ((event.which == 13) || (event.keyCode == 13))
{
event.cancelBubble = true;
event.returnValue = false;
document.getElementById('" + sSearchButtonClientId + @"').click();
}
};";
SearchTextBox.Attributes.Add("onkeydown", sCommand);

But this approach worked in IE, Chrome and didn't work in FF.

Here is the code which workes also in FF:

// "Search button click" when hitting enter on SearchTextBox - FireFox!
string sSearchButtonClientId = SearchImageButton.ClientID;
string sCommand =
@"if (event.which || event.keyCode)
{
if ((event.which == 13) || (event.keyCode == 13))
{
event.cancelBubble = true;
document.getElementById('" + sSearchButtonClientId + @"').click();
return false;
}
};";
SearchTextBox.Attributes.Add("onkeydown", sCommand);


I have replaced "event.returnValue = false;" with "return false;" and that's it.
Left by SGG on Nov 01, 2009 11:45 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
var msg = document.getElementById("text1").value;
msg = s;

this code didn't work in firefox :((
Left by Masoud iLDEREMi on Dec 27, 2009 2:51 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
I have also seen that getElementByID() is case sensitive in FF and not in IE. So just in case if you have mixed case IDs make sure that you pass in the exact string to this function.

Thanks,
Pratheesh
Left by Pratheesh on Feb 18, 2010 5:50 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
AWESOME THNKS ANDREW!
Left by faby on Sep 02, 2010 10:40 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
document.form1.file1.value
or
document.getElementById(id).getAttribute("value")
only give file name not full path as ie

I want full path in ff also.
Left by sunil on Sep 15, 2010 3:13 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
i have the same problem

code works with ie but not ff

document.getElementById('ass_id').value

says undefined index in ff

PLease help!
Left by Isha on Mar 08, 2011 11:29 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
I need to call one method from flash. flash method name is getGreenMC()
I doing like this... but it's not working
document.getElementById("id").getGreenMC()
Left by Kumar on May 30, 2011 7:17 AM

# re: document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
I'm a newbie to web development and I sincerrely feel that these kinds of menacing nuances should be comprehensively be posted on the official forums such as W3C schools etc.. since this saves a lot of time and frustration for especially greenhorns like me. Thanks to guys like yourself for posting this valuable piece of information, my sincere appreciations.

Left by Sriram on Sep 22, 2011 12:35 PM

# document.getElementById(tableID)
Requesting Gravatar...
working in ie8 but not in firefox
Left by Nilesh on Sep 12, 2012 6:39 AM

# SOLVED!!!! document.getElementById(id).getAttribute("value") on FireFox
Requesting Gravatar...
we solve this issue: assing id to input name :
:
<input name="code" id="code">

** if you put getElementById("code")
check first id="code" exist!!
Left by julio montoya on Sep 24, 2013 3:42 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Hibbard | Powered by: GeeksWithBlogs.net