<
script language
=
"
javascript
"
>
function showhtml() ... {
alert(tf2.value);
}
function insertImg() ... {
var theImage="http://www.baidu.com/img/logo-yy.gif";
if (document.selection)
...{
theSelection = document.selection;
theRange = theSelection.createRange();
theRange.collapse(false);
theRange.pasteHTML("<img src="" + theImage + "" />");
}
}
第二种方法:
theRange = theSelection.getRangeAt( 0 );
theRange.collapse( false );
var theImageNode = theIframe.contentWindow.document.createElement( " img " );
theImageNode.src = theImage;
theImageNode.alt = theAlt;
theRange.insertNode(theImageNode);
function showhtml() ... {
alert(tf2.value);
}
function insertImg() ... {
var theImage="http://www.baidu.com/img/logo-yy.gif";
if (document.selection)
...{
theSelection = document.selection;
theRange = theSelection.createRange();
theRange.collapse(false);
theRange.pasteHTML("<img src="" + theImage + "" />");
}
}
第二种方法:
theRange = theSelection.getRangeAt( 0 );
theRange.collapse( false );
var theImageNode = theIframe.contentWindow.document.createElement( " img " );
theImageNode.src = theImage;
theImageNode.alt = theAlt;
theRange.insertNode(theImageNode);