473,738 Members | 2,009 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
XMLHttpRequest.

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 5129
For the record books here's the javascript:

/*
*This function is in the parent window and is called by the child
window...
*/
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
problems
*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 =
quantity;
if (document.getEl ementById('' + item + '_baseQty'))
document.getEle mentById('' + item + '_baseQty').inn erHTML =
baseQty;
if (document.getEl ementById('' + item + '_price'))
document.getEle mentById('' + item + '_price').inner HTML =
price;
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 =
unit;
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 =
sales;
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
the
* 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
itself.
*/
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
feedback.

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 =
quantity;
if (document.getEl ementById('' + item + '_baseQty'))
document.getEle mentById('' + item + '_baseQty').inn erHTML =
baseQty;


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
source'.

I hope that helps.

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

--
Rob
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
normally).


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

Martin Honnen
http://JavaScript.FAQTs.com/
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.

Thanks.

Jul 5 '06 #5

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

Similar topics

2
9564
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 other tables input boxes
2
6370
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 function. But when I make the element id a string variable as below it doesnt work. So, I'd like to do...
2
1847
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.
2
3172
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 whats the prob.this is the code i m using: <? include("config.inc.php"); //error_reporting(0); ...
5
2558
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. In Firefox it displays fine but when I submit the form the name and value for the select tag are...
7
3555
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 off some tags. There goes my code:- HTML:- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
3
2611
rizwan6feb
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 from The Form Validation) which sends 300 requests with an interval of 10 miliseconds and displays the...
1
1620
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.
8
3142
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 concerned, this means that (1) I cannot use 3rd party libraries, which is why I've implemented my own...
0
8787
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9259
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8208
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
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 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.