![]() |
#2
lele20072010-09-04 21:01
|
想做到兼容,用了下面的代码:

window.isIE = (navigator.appName == "Microsoft Internet Explorer"); //判断是否为IE浏览器!
//插入HTML代码...
function insertHTML()
{
var html = "<embed src=http://player. quality=high pluginspage=http://www. type=application/x-shockwave-flash width=600 height=500></embed>";
var leleHTML = $('leleEditor').contentWindow;
leleHTML.focus();
if(window.isIE)
{
var o = leleHTML.document.selection.createRange();
o.pasteHTML(html);
alert(html);
}
else
{
leleHTML.document.execCommand("insertHTML",false,html);
alert(html);
}
}
//插入HTML代码...
function insertHTML()
{
var html = "<embed src=http://player. quality=high pluginspage=http://www. type=application/x-shockwave-flash width=600 height=500></embed>";
var leleHTML = $('leleEditor').contentWindow;
leleHTML.focus();
if(window.isIE)
{
var o = leleHTML.document.selection.createRange();
o.pasteHTML(html);
alert(html);
}
else
{
leleHTML.document.execCommand("insertHTML",false,html);
alert(html);
}
}
在IE里可以插入flash内容。。在FF下没有效果。。不显示任何内容。。

window.isIE = (navigator.appName == "Microsoft Internet Explorer"); //判断是否为IE浏览器!
//插入HTML代码...
function insertHTML()
{
var html = '<font color="red">乐乐</font>';
var leleHTML = $('leleEditor').contentWindow;
leleHTML.focus();
if(window.isIE)
{
var o = leleHTML.document.selection.createRange();
o.pasteHTML(html);
alert(html);
}
else
{
leleHTML.document.execCommand("insertHTML",false,html);
alert(html);
}
}
//插入HTML代码...
function insertHTML()
{
var html = '<font color="red">乐乐</font>';
var leleHTML = $('leleEditor').contentWindow;
leleHTML.focus();
if(window.isIE)
{
var o = leleHTML.document.selection.createRange();
o.pasteHTML(html);
alert(html);
}
else
{
leleHTML.document.execCommand("insertHTML",false,html);
alert(html);
}
}
var html = '<font color="red">乐乐</font>';
html变量内容是这个或其它简单的html标签时,FF下也是有效果的。。
请问这个兼容性怎么处理的呀?