473,385 Members | 1,848 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,385 software developers and data experts.

javascript to move a DIV using the DOM

I'm trying to move a DIV element to before one of its siblings using a
javascript function.

This works fine on most browsers:

function putdivbefore(divtomove, divtarget)
{
var mydiv1 = document.getElementById(divtarget);
var mydiv2 = document.getElementById(divtomove);
mydiv1.parentNode.insertBefore(mydiv2, mydiv1);

}
On IE, however, it gives spotty results. In a simple test page it
works fine, but when the page is more complex, it causes the browser
to stop loading the page and return "Operation was aborted."

Can anyone point me to a resource for this?

Thanks,

g.
Jun 27 '08 #1
2 2283
Graham Charles wrote:
I'm trying to move a DIV element to before one of its siblings using a
javascript function.

This works fine on most browsers:

function putdivbefore(divtomove, divtarget)
{
var mydiv1 = document.getElementById(divtarget);
var mydiv2 = document.getElementById(divtomove);
mydiv1.parentNode.insertBefore(mydiv2, mydiv1);

}

On IE, however, it gives spotty results. In a simple test page it
works fine, but when the page is more complex, it causes the browser
to stop loading the page and return "Operation was aborted."
What do you mean by "stop loading"? Are you saying that you are trying
to modify the document tree while the document is still loading? Weird
behavior would not be surprising then.

If yes, which would explain why it works with short/simple documents (they
load fast enough and have less to be parsed), wait until the `load' event
of the document occurs before you modify the document tree.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #2
* Graham Charles wrote in comp.lang.javascript:
>On IE, however, it gives spotty results. In a simple test page it
works fine, but when the page is more complex, it causes the browser
to stop loading the page and return "Operation was aborted."
You may be experiencing a problem like this:

* http://blogs.msdn.com/ie/archive/200...n-aborted.aspx

Also see the documents linked from there.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #3

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

Similar topics

9
by: Phil Powell | last post by:
I am producing a form using PHP on the back end and Javascript on the front end. The resulting script will come to the browser as follows: <script> <!-- function selectAll() { moveElement =...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
1
by: Rob | last post by:
I have a date text box (input type = text) in an ASP.NET/Javascript environment. I wanted to force the users to enter dates in a "__/__/____", "dd/mm/yyyy" or similar format. The textbox needs to...
2
by: MStepansky | last post by:
Any ideas of some of the good Javascript books that involves graphics programming: - to be able to move the images pixelwisely. - to be able to grab an image and move it around on screen (on...
1
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
13
by: Andy Baxter | last post by:
Can anyone recommend a good online guide to using objects in javascript? The book I bought (DHTML Utopia) suggests using objects to keep the code clean and stop namespace clashes between different...
1
by: Ian Davies | last post by:
I am trying to move some text by clicking a button. When clicked the button runs the java script and this will then take the value in the text field and add 10 to it to create a new value, this is...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...

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.