473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Javascript web browser script not working

Internet Explorer 7 does not handle buttons correctly since it sends the text between <button> and </button>rather than the value. (Weird but true.) This Javascript is supposed to correct this by sending the value of the button onClick. But it does not work. Can anybody see the error ?

I use this to attach the Javascript file in HTML5 :

Expand|Select|Wrap|Line Numbers
  1. <script src="buttonfix.js"></script>
Contents of buttonfix.js :

Expand|Select|Wrap|Line Numbers
  1. function runonclick()
  2. {
  3.     var count = 0;
  4.     var formlength = this.form.elements.length;
  5.     while(count < formlength)
  6.     {
  7.         if(this.form.elements[count].tagName.toLowerCase() == "button")
  8.         {
  9.             this.value = this.attributes.getNamedItem("value").nodeValue;
  10.         }
  11.  
  12.         count++;
  13.     }
  14. }
  15.  
  16. function buttonfix()
  17. {
  18.     var buttonarray = document.getElementsByTagName("button");
  19.  
  20.     var count = 0;
  21.     var buttonarraylength = buttonarray.length;
  22.     while(count < buttonarraylength)
  23.     {
  24.         buttonarray[count].onclick = runonclick;
  25.  
  26.         count++;
  27.     }
  28. }
  29.  
  30. window.attachEvent("onload", buttonfix);
  31.  
Jun 25 '11 #1
1 1729
Dormilich
8,658 Expert Mod 8TB
Internet Explorer 7 does not handle buttons correctly since it sends the text between <button> and </button>rather than the value.
which is exactly what it is supposed to do, since the <button> element does not have a value attribute (compare to <textarea>).
Jun 27 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Rune Strand | last post by:
What would it take to create a Firefox extension that enables Python as a script language in the browser - just like Javascript? Is it at all possible? Are the hundred good reasons not to bother? ...
11
by: Sebastian Schöps | last post by:
Hello all, I have to access a website which does a stupid browser check and only accepts Netscape 4.7. The problem is that I have to access the website with Mozilla or Internet Explorer. ...
6
by: simon | last post by:
hello, what code would i use to kick off a javascript script after i had registered it? If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then Page.RegisterClientScriptBlock("jsScript",...
6
by: ernesto.tejeda | last post by:
Hello, I have a couple of questions regarding the loading of .js files for the browser and would like anyone to point me wher to find the answer (or if you know the answer and tell me will do just...
3
by: rajasree | last post by:
Hi all, am doing a project in PHP. my javascript code is working properly in ie. But its not working in firefox. Please help me my code is as follows; <script language="javascript"...
4
by: itgaurav198 | last post by:
Hi, I have the following two problems. 1. The following script is Working in IE and not in Mozilla Firefox i.e. it si not setting the value of the textbox. <input type="text" name="notify">...
13
vikas251074
by: vikas251074 | last post by:
When change the <script language="javascript"> to <script type="text/javascript">, javascript function now works no more. Previously it was working. Javascript function is given below - function...
16
by: srinathpandit | last post by:
Hi, The below javascript is not working in the firefox, Please help me.. <script> function Login(){ var done=0; var username=document.login.username.value; username=username.toLowerCase();...
1
by: vinodkizhussery | last post by:
my javascript code is working in ie but not in mozila why ? how can i solve this problem. my code is attached...
8
by: kkshansid | last post by:
external javascript file not working on server <script type="text/javascript" src="../include/common.js"></script> while internal wrking fine <script language="JavaScript"> . . </script> i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.