473,670 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assigning innerHTML of one div to another div, not reflecting immediately

11 New Member
Hi,

Am assigning the innerHTML of a div to another div, the problem is that the assigned innerHTML is not reflected when i display the second div to which i have assigned the innerHTML of the first div in firefox, but it works fine in othe browsers.

I also observed that, the assigned innerHTML to the second div is reflecting after some time. Why's it reflecting after some time.
Mar 5 '07 #1
24 5816
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TheScripts.

Please post your code.
Mar 5 '07 #2
sumittyagi
202 Recognized Expert New Member
yea! firefox creates problems many times while using innerHTML property.
So I believe in manipulating DOM for that purpose, it is always reliable.

I also use the innerHTML property, but whenever there is plain text involved, then I rely on manipulate DOM.

I suggest you the same. It's my personal experience, but don't fully rely on me, as I am not an expert, wait for expert's advices.
Mar 5 '07 #3
ManjunathRatakonda
11 New Member
Here's the code

Firstly i have two divs i) Outer Div namely 'DivCartLayer' ii) inner Div 'divCartContent s'.

var strHTMLOutput=" <Html will be generated dynamically>"

1) The newly formed html will be assigned to inner Div as follows
document.getEle mentById('divCa rtContents').in nerHTML=strHTML Output;


Here am using 'testDIV' a new div, which i use for sliding the layer(cart data).
For this i use

document.getEle mentById('testD IV').innerHTML= document.getEle mentById('DivCa rtLayer').inner HTML;


Once i assign the outer div's innerHTML to the new div, i use the following functions to slide the new div.


<script language="JavaS cript1.2">
maxTopPx = -160;
maxBottomPx = 150;

themenu = document.all.te stDIV.style

function pull()
{
if (window.drawit)
clearInterval(d rawit)

pullit = setInterval("pu llengine()",10)
}

function pullengine()
{
if (parseInt(theme nu.top) < maxBottomPx)
themenu.top=par seInt(themenu.t op)+10+"px"
else //if (window.pullit)
{
clearInterval(p ullit)
//clearInterval(c artLayerId)
document.getEle mentById('divCa rtContents').st yle.overflow = 'auto';
}
}

function draw()
{
document.getEle mentById('divCa rtContents').st yle.overflow = "hidden";

clearInterval(p ullit)

drawit = setInterval("dr awengine()", 5)
}

function drawengine()
{
if (parseInt(theme nu.top)>maxTopP x)
themenu.top = parseInt(themen u.top)-10+"px"
else //if (window.drawit)
{
clearInterval(d rawit)
themenu.top=max TopPx
}
}
</script>


Here am getting 2 problems.

1) After assigning the outer div's HTML to the new div 'testDIV', when this div slides down i am not able to see the latest generated html.it always shows the old html.

2) If i scroll a div under any other div's in firefox , its flickering(on FF and netscape),but working fine in IE6,IE7,Safari. So i hided the scroll when its scrolling and once the scrolling is complete i made the scroll visible.
Then also its not working in ff and netscape.
Mar 5 '07 #4
ManjunathRatakonda
11 New Member
Hi,

Can u post me the code, the way in which we can proceed by using dom.

Thanks in Advance.
Mar 5 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
The line
Expand|Select|Wrap|Line Numbers
  1. themenu = document.all.testDIV.style
should be
Expand|Select|Wrap|Line Numbers
  1. themenu = document.getElementById('testDIV').style
document.all is IE-specific, Use the standard getElementById.
Mar 5 '07 #6
ManjunathRatakonda
11 New Member
changed as specified. Thanks.
Mar 5 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Did it work then?
Mar 5 '07 #8
ManjunathRatakonda
11 New Member
No. The same problem persists.
Mar 5 '07 #9
sumittyagi
202 Recognized Expert New Member
Hi,

Can u post me the code, the way in which we can proceed by using dom.

Thanks in Advance.
I would suggest to search out for the functioning of the following functions:-
document.getEle mentById(id);
elemRef.appendC hild(childRef);
elemRef.removeC hild(childRef);
elemRef.insertB efore(oldChildR ef, newChildRef);
document.create Element(tagName );
document.create TextNode(text);

in addition search out for some properties
elemRef.firstCh ild
elemRef.lastChi ld
elemRef.childNo des (it is an array)
elementRef.pare nt (parent of the elemRef element).

Knowing these properties and methods you can manipulate DOM easily.

the functioning of functions and properties are self explainatory!
But if you find any problem in any of them them I will send you the explaination also.

Now moving to your context.(I can only guide you, real work is to be done by you only, because it is only you who understands the scenario of your problem)

let's say your div's ID are fdiv, and sdiv.

now append all the childs of fdiv in sdiv.
var sourceDiv = document.getEle mentById('fdiv' );
var destDiv = document.getEle mentById('sdiv' );
for(var i=0; i<sourceDiv.chi ldNodes.length; i++)
{
destDiv.appendC hild(sourceDiv. childNodes[i]);
}

all the nodes of fdiv will be added to sdiv;

I hope this helps
Mar 5 '07 #10

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

Similar topics

6
10131
by: adamrfrench | last post by:
Let it be mentioned that Javascript is not my forte, so the solution to this could very well be a simple one. I am working on an AJAX function where I can pass a URL and the target ID in, and have the function update the target ID with the URL. There is a bit more to it then that, but that is the basics. my difficulty comes when I try to assign a variable to: "document.getElementById('-> var gose here <-').innerHTML"
14
74843
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0; myarray=0; myarray=1; myarray=8;
8
1685
by: Doug Lerner | last post by:
I have this snippet of client side code running: var makeField = document.forms; alert("makeFieldName name,length,type=" + makeFieldName + ", " + makeField.name + "," + makeField.length + "," + makeField.type); The alert is just in there for debugging.
6
2990
by: sonic | last post by:
Ok, i am sure everyone is sick of hearing about this. but i've checked about 10 different posts/sites about this issue, and they all say "use DOM" but i think there is more to be said. Perhaps I am a total newbie but the answer was not immediately obvious to me here. so.. problem: declaring doctype as xhtml will prevent myDiv.innerHtml=val from working. suggested solution:
7
2524
by: Ron Goral | last post by:
Hello I am new to creating objects in javascript, so please no flames about my coding style. =) I am trying to create an object that will represent a "div" element as a menu. I have written several methods that are working fine. The problem is if I want to dynamically assign an event handler to the object, the event handler is not called. What am I doing wrong? Below is a sample HTML doc with everything in place. <!DOCTYPE HTML PUBLIC...
4
5710
by: chu2ch | last post by:
Good Afternoon Folks, Im kinda in a pickle. I have created a .net 2.0 dll written in vb.net that needs to reside in a folder on a networked computer ( for compatibility with another program). How can I add that reference to my client project on my development machine that will consume that dll. please keep in mind that the computer name or path may change. Thanks in advance.
6
5573
by: google | last post by:
I am having trouble with the following function that I am modifying from www.isocra.com. I am trying to change the ID of a hidden form object inside a table row. I have used alert() to test where it breaks and it seems to be on the last line of the function where I am trying to place the new text back into the table row. Anyone any ideas where I a going wrong as I'm not a great Javascript coder. Thanks in advance. this.onDrop =...
1
1153
by: Shana | last post by:
Hi all, can anyone answer my query: Actually i making changes in my javascript code and when i am running my page in the browser it is not reflecting the change immediately. Sometime it reflects after 20 mins or some time 2-3hrs or more. Can any one tell me the reason behind it. my javascript is written only for IE and i have a IE browser only. .... Is there some thing browser caches some scripts? so it fetching the previous stored...
6
4231
by: PaPa | last post by:
I'm not sure this is a javascript issue or an HTML issue. I notice that when I extract the contents of a div using the innerHTML property (?), that I wind up with a literal variable (?) which exactly matches the contents of the div with one exception. It seems that whenever the code includes a tag which uses the forward slash against the closing bracket (say the break tag ..... />) that the browser, or HTML, or javascript, or...
0
8466
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
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,...
1
8591
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,...
1
6212
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
5683
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
4208
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...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
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
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.