Safari DOM not resetting when layer changed

T

timchalk

I believe I've found a problem with the Safari DOM when updating the
text found within a layer. Although the layer is updated correctly
visually, the underlying DOM seems to grow larger with duplicated
elements rather than being reset with the new elements. I've created a
test page which demonstrates this issue...

http://www.qas.com/layer-test.htm

The page contains an initially empty <div> element within <form> tags.
When the page loads the div is populated with an input field and a
button using Dreamweaver's MM_setTextOfLayer function. The action on
the button is to update the div with some new form elements and alert
the form collection. The updated div contains a button which sets the
div back to its original state and again alerts the form collection.
This does exactly what you expect in IE, Firefox, NS6+, Opera, with
just the form elements visible on the page being alerted, but in Safari
the form collection just keeps growing as you move back and forth using
the buttons.

Is there another way to do this in Safari or is a bug with the program?

Thanks in advance for any help!

Tim
 
R

RobG

I believe I've found a problem with the Safari DOM when updating the
text found within a layer. Although the layer is updated correctly
visually, the underlying DOM seems to grow larger with duplicated
elements rather than being reset with the new elements. I've created a
test page which demonstrates this issue...

http://www.qas.com/layer-test.htm

The page contains an initially empty <div> element within <form> tags.
When the page loads the div is populated with an input field and a
button using Dreamweaver's MM_setTextOfLayer function. The action on
the button is to update the div with some new form elements and alert
the form collection. The updated div contains a button which sets the
div back to its original state and again alerts the form collection.
This does exactly what you expect in IE, Firefox, NS6+, Opera, with
just the form elements visible on the page being alerted, but in Safari
the form collection just keeps growing as you move back and forth using
the buttons.

Is there another way to do this in Safari or is a bug with the program?

I'd like to blame that dreadful MM_ code, or innerHTML, but it is a
bug with Safari that removed form elements aren't really removed.

<URL:http://www.quirksmode.org/bugreports/archives/2004/11/safari_and_docu.html>

other Safari bugs are listed at Quirksmode here:

<URL:http://www.quirksmode.org/bugreports/archives/safari/>

Here's a simple test script:

<form action="">
<input type="text" name="num" width="30"><br>
<input type="button" value="Add a button" onclick="
var oInp = document.createElement('input');
oInp.type = 'button';
oInp.value = 'Delete me';
oInp.onclick = function() {
this.form.removeChild(this);
}
this.form.appendChild(oInp);
this.form.num.value='There are '
+ this.form.elements.length + ' elements';
">
</form>

I'd suggest re-writing that awful MM_ stuff to be cleaner and leaner
and replace innerHTML with DOM.

Get rid of the " /* <![CDATA[ */ " comment delimiters inside the
script element - your doctype is HTML and therefore they aren't
required at all. Similarly, the use of " />" indicates XHTML, but
your doctype is HTML.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top