473,573 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with .innerHTML, AJAX and Firefox

My problem appears to be Firefox specific.

I have a hyperlink that loads a new window. This window contains
hyperlinks that call javascript functions in the parent window and then
closes the child window. The function that is called contains an

My problem is that everything happens as it should, the innerHTML is
changed by the results of the XMLHttpRequest and the child window
closes. The problem is this, in Firefox, the screen doesn't display the
change until I click anywhere on the parent window. Then the element(s)
update with their new values. In IE and Opera it works on the fly.

I've tried things like setting focus on the parent window and even
setting focus in an element inside a form. These focus calls happen (I
can see the cursor appear in the form element) but it still doesn't
update the screen until I click on it.

This is in an intranet application so I can't provide a hyperlink to
the page. If anyone knows what I'm talking about that would be awesome.
If not I can probably cut and paste the relevant code although it might
be quite a bit.

Again, this only happens in Firefox and appears to be some sort of
refresh/focus problem. Thanks for your help.

Jun 30 '06 #1
4 5121
For the record books here's the javascript:

*This function is in the parent window and is called by the child
function getSelectedPric eBreak(item, quantity) {
if (document.getEl ementById(item) ) {
document.getEle mentById(item). value = quantity;
this.window.foc us();
checkPrice(item );
document.getEle mentById(item). focus();

*This method is the parent window and is called by either the method
above or
*via onBlur() events by various form components. When called by
onBlur() on a form
* component the update is immediate in all browsers. It's only when
called by
* getSelectedPric eBreak (via a child window) that the update doesn't
appear in Firefox
* until the user clicks anywhere in the parent window.
function checkPrice(para m) {
if (document.getEl ementById(param )) {
request = getRequest(upda tePrice);
var value = document.getEle mentById(param) .value;
request.open("G ET", "/portal/servlet/update.do?item= " + param +
"&qty=" + value, true);
request.send(nu ll);
else {
alert("Can't find the element.");

*This method is called onreadystatecha nged. There are no execution
*whatsoever, just view issues in Firefox.
function updatePrice() {
if (request.readyS tate == 4) {
if (request.status == 200) {
var xmldoc = request.respons eXML.documentEl ement;
var item =
xmldoc.getEleme ntsByTagName('i tem')[0].firstChild.dat a;
var quantity =
xmldoc.getEleme ntsByTagName('q uantity')[0].firstChild.dat a;
var baseQty =
xmldoc.getEleme ntsByTagName('b aseQty')[0].firstChild.dat a;
var price =
xmldoc.getEleme ntsByTagName('p rice')[0].firstChild.dat a;
var basePrice =
xmldoc.getEleme ntsByTagName('b asePrice')[0].firstChild.dat a;
var unit =
xmldoc.getEleme ntsByTagName('u nit')[0].firstChild.dat a;
var baseUnit =
xmldoc.getEleme ntsByTagName('b aseUnit')[0].firstChild.dat a;
var um =
xmldoc.getEleme ntsByTagName('u m_description')[0].firstChild.dat a;
var sales =
xmldoc.getEleme ntsByTagName('s ales')[0].firstChild.dat a;
var total =
xmldoc.getEleme ntsByTagName('t otal')[0].firstChild.dat a;
if (document.getEl ementById(item) )
document.getEle mentById(item). value = quantity;
if (document.getEl ementById('' + item + '_qty'))
document.getEle mentById('' + item + '_qty').value =
if (document.getEl ementById('' + item + '_baseQty'))
document.getEle mentById('' + item + '_baseQty').inn erHTML =
if (document.getEl ementById('' + item + '_price'))
document.getEle mentById('' + item + '_price').inner HTML =
if (document.getEl ementById('' + item + '_basePrice'))
document.getEle mentById('' + item + '_basePrice').i nnerHTML
= price;
if (document.getEl ementById('' + item + '_unit'))
document.getEle mentById('' + item + '_unit').innerH TML =
if (document.getEl ementById('' + item + '_baseUnit'))
document.getEle mentById('' + item + '_baseUnit').in nerHTML
= baseUnit;
if (document.getEl ementById('' + item + '_um'))
document.getEle mentById('' + item + '_um').innerHTM L = um;
if (document.getEl ementById('' + item + '_sales'))
document.getEle mentById('' + item + '_sales').inner HTML =
if (document.getEl ementById('_tot al'))
document.getEle mentById('_tota l').innerHTML = total;

*This function is in the parent window and opens the child window when
* appropriate hyperlink is clicked.
function viewBreaks(item ) {
window.open('/portal/webapps/customers/orders/breaks.jsp?item =' +
item, 'PriceBreaks',
'width=200,heig ht=200,status=n o,toolbar=no,sc rollbars=yes');

*This is the onclick event registered with the hyperlink in the CHILD
window. It blurs
* itself (in an attempt to give focus back to the parent window first)
and then calls
* the getSelectedPric eBreak method in the parent window, then closes
onclick="javasc ript:window.blu r();
window.opener.g etSelectedPrice Break('33500-00002', '1080');
window.close(); return false

*Just for kicks, this is the onblur event handler that works just fine
in the parent
* window for all browsers.
onblur="javascr ipt:checkPrice( '33114-00050');"

Again, all the execution steps happen without error on all browsers.
Only in Firefox
the component changes made in the updatePrice method don't appear until
the user clicks in the window (IE, Opera and Netscape all work
normally). Problem is I used AJAX so the user would get instantaneous

Thanks again.

Jun 30 '06 #2
tc****@gmail.co m wrote:
For the record books here's the javascript: [...]
if (document.getEl ementById('' + item + '_qty'))
document.getEle mentById('' + item + '_qty').value =
if (document.getEl ementById('' + item + '_baseQty'))
document.getEle mentById('' + item + '_baseQty').inn erHTML =

What are you trying to change using innerHTML? Changing the value
attribute in Firefox will not modify the element's innerHTML. Use DOM
methods only, not innerHTML.

innerHTML is a proprietary Microsoft invention that has been widely
copied. Since there is no public standard, implementations differ[1].
One of the most obvious is that IE updates the element's innerHTML
property to reflect its current HTML, Firefox tends to keep the
innerHTML property as it was when the page loaded - essentially a 'view

I hope that helps.

1. A public standard would not guarantee consistent implementation, but
it would probably help.

Jun 30 '06 #3

tc****@gmail.co m wrote:

Again, all the execution steps happen without error on all browsers.
Only in Firefox
the component changes made in the updatePrice method don't appear until
the user clicks in the window (IE, Opera and Netscape all work

Netscape works fine and Firefox does not? Which versions of Netscape
respectively Firefox have you tried that?

Martin Honnen
Jul 1 '06 #4
Sometimes I wonder where my brain is...

I was setting focus to the window and component but it wasn't updating
because the event was fired by onblur. I simply called
document.getEle mentById('id'). blur() and all is updating fine.


Jul 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: sveinn | last post by:
Hi all, I've read through this group searching for an answear about this problem. Few have come close but not quite what I need. My problem is this: I'm using Ajax to fetch a new table with input boxes. I then take the innerHTML from my <div> and add the new table to the existing one/s. What happens in FireFox is that all values in...
by: jfaulky | last post by:
Hi all, I have a simply AJAX function that I pass a URL and it returns its contents to a <DIV id="mydivname"> area of my screen. All works fine when I manually enter: document.getElementById('mydivname').innerHTML="<div>Loading, please be patient....<div>"; However, I'd like to make it more functional by passing any div name to the...
by: K. | last post by:
Hello! I have the following problem. I have form div which is replaced by ajax event. Unofrtunately all the ajax inputs are null after posting the form (method="post") in Firefox, but on screen they are filled in (not null values). On Internet Explorer 7.0 everything works fine. After posting the form all ajax inputs are not empty.
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand...
by: pjdeklerk | last post by:
I have a web page which has javascript which uses the innerHTML property of a <TD> object to replace that table cell's contents. The contents are of the form <span><select><option1.../><option2..>...</select></span> (in engish, the <td> contains a <span> which contains a <select> which contains some number of <option>s. It works fine in IE. ...
by: RaefKandeel | last post by:
Hi all, this is my first post. I have a little ajax assignment that works fine on mozilla firefox 2.0, but doesn't work at all on Internet Explorer 7. Apparently it has to do with the line where tempDiv element takes the value from xhr.responseText. The line that says: tempDiv.innerHTML= xhr.responseText;. Apparently Internet Explorer 7 cuts...
by: rizwan6feb | last post by:
Hi experts! Recently i was working on "Form Validation Using Ajax". My form validation was creating problem, when a user changes focus too quickly. I had a post related to this, but was unable to solve the problem. Here is the previous post http://bytes.com/forum/thread798289.html Trying to trace the problem I have written a code (Separate...
by: Robin | last post by:
Martin wrote: .... You appear to be putting the responseText into DIV 'htmlText' then 'hiddenDiv'. You therefore have two DIVs with id 'divslct4' (not legal as IDs are supposed to be unique). Your code is changing (and reporting that state of) the hidden one and hence the visible one isn't changing.
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox" post. Third, there are pieces of this code that I am not at liberty to display, change, discuss, or re-implement. As far as this question is...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.