R
RobG
It seems that Safari doesn't implement the innerHTML property for
dynamically created elements in XHTML documents, although it does work
for in-line elements.
It also seems that Safari uses the file extension to detect XHTML
rather that the DOCTYPE. There's a test case below, save it to files
with .xhtml and .html extensions and open in Safari to see the
difference. Tested in 3 on Mac.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>innerHTML test</title>
<script type="text/javascript">//<![CDATA[
function foo() {
var div = document.createElement('div');
var div1 = document.getElementById('div1');
var div2 = document.getElementById('div2');
div1.innerHTML = 'In-line div worked';
div2.appendChild(div);
div.innerHTML = "Scripted div worked.";
}
window.onload = foo;
// ]]></script>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
</body>
</html>
dynamically created elements in XHTML documents, although it does work
for in-line elements.
It also seems that Safari uses the file extension to detect XHTML
rather that the DOCTYPE. There's a test case below, save it to files
with .xhtml and .html extensions and open in Safari to see the
difference. Tested in 3 on Mac.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>innerHTML test</title>
<script type="text/javascript">//<![CDATA[
function foo() {
var div = document.createElement('div');
var div1 = document.getElementById('div1');
var div2 = document.getElementById('div2');
div1.innerHTML = 'In-line div worked';
div2.appendChild(div);
div.innerHTML = "Scripted div worked.";
}
window.onload = foo;
// ]]></script>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
</body>
</html>