Mozilla, Midas og createRange()
Hej!Jeg har lidt problemer med at forstå forskellen på IE's DHTML implementering, og Midas implementering.
Hvad er det i nedenstående der gør at det ikke virker i Mozilla?
Jeg får en JS fejl der hedder sådan her:
Error: document.getElementById("my").contentWindow.document.selection has no properties
Source File: http://localhost/editor/Untitled1.php#
Line: 25
Herunder mit script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
///////////Make iframe editable//////////
function getIFrameDocument(aID){
if(document.getElementById(aID).contentDocument){
return document.getElementById(aID).contentDocument;
} else {
return document.frames[aID].document;
}
}
/////////////////////////////////////////
function load(){
getIFrameDocument('my').designMode = "On";
document.getElementById('my').contentWindow.focus();
}
function mytest() {
var str = document.getElementById('my').contentWindow.document.selection.createRange();
str.text = "Hej med dig";
}
</script>
</head>
<body onload="load()">
<a href="#" onclick="mytest()">Link</a>
<iframe id="my" src="content.html"></iframe>
</body>
</html>
På forhånd tak
