Solved

using insertAdjacentHTML and innerHTML in tandem.

Posted on 2003-10-25
7
211 Views
Last Modified: 2008-02-01
I am currently using a script that writes everything in a div tag to a seperate frame's div tag using the innerHTML property. Instead of writing redundant information over and over I would prefer to use the insertAdjacentHTML command.  So basically I would have a function I could use similar to this.

parent.frames.frame1.document.getElementById("text").insertAdjacentHTML("beforebegin", innerhtmlhere);

where innerhtmlhere would refer to the current page's division tag and then it would be sent to the other frame's division tag, but would not overwrite the html code that was already inside.  It's somewhat tough to explain what I am looking for and Im still quite new to javascript so I am not sure who else to ask or where else to look.  Any help would be greatly appreciated.
0
Comment
Question by:SaF3R
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Assisted Solution

by:Xxavier
Xxavier earned 62 total points
Comment Utility
Does'nt this do it?

parent.frames.frame1.document.getElementById("text").innertHTML+=innerHTML of the div tag to be sent over.

i.e.
 parent.frames.frame1.document.getElementById("text").innertHTML+= document.getElementById(innerhtmlhere).innerHTML
0
 
LVL 10

Accepted Solution

by:
NetGroove earned 63 total points
Comment Utility
The adjacent method goes like this:

rfd=parent.frames.frame1.document.getElementById('text');
rfd.insertAdjacentHTML('beforebegin', document.getElementById('senderDiv').innerHTML);

But that will work only in IE.

Recomanded version simmelar to Xxavier proposal is:
rfd=parent.frames.frame1.document.getElementById('text');
rfd.innerHTML=document.getElementById('senderDiv').innerHTML+rfd.innerHTML;

Only difference is that my proposal puts the sender div html Before reciver text html, and not appended.


0
 
LVL 7

Expert Comment

by:Xxavier
Comment Utility
Netscape does not include the innerText or outerHTML properties as part of the Object Model  either. By usung the assignment operator you can out the innerHTML at either end of the receiver HTML as NetGroove has pointed out., bt simply ordering the stringexpession appropriately
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:SaF3R
Comment Utility
Thanks to both of you for your help on this.  As I said I'm still quite new at this  and I did try using the concatenation method that you both proposed, but somewhere down the line I must have tripped myself up.  Im not sure who to give the points to on this one because both of you did add helpful pointers so I'll split'em.  It's amazing how much better this forum is than others, and Im grateful I tried here first.
0
 
LVL 10

Expert Comment

by:NetGroove
Comment Utility
Thanks for the points.

And I would like to encourage you to do the points splits also in the future.
From my point of view is this not a quiz who gives the fastest and best answer to catch the points.
It is more a way for you to say Thank You to those experts who invested their valuable time to help you to find your solution.

Of course is on experts side still the competition who plays best the game :-)

See you,
NetGroove

0
 

Author Comment

by:SaF3R
Comment Utility
To anyone interested, it turns out that for my situation the insertadjacenthtml method was the only one to fully solve the problem I was having.  If you have image tags in the section you want to append to, they will reload each time you send information, which for me was undesirable due to a large number of images(also for security purposes they are coming from a db which is extra slow and can cause a serious slowdown if you're constantly loading and reloading images).  So when I used the insertadjacenthtml method, the images did not reload and everything works fine(for IE that is).
0
 
LVL 10

Expert Comment

by:NetGroove
Comment Utility
Thanks for sharing this information with us.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now