<td class="productDesc"><div id="divProductENDesc">
<iframe src="Fckeditor\ProductEditor.htm" width="100%" height="800" scrolling="Auto" frameborder="0" id="iProductENDesc" border=0></iframe>
</div>
如上代码所示,
在ProductEditor.htm中有个SetHtml的方法定义,
js中怎么调用iProductENDesc框架中的这个方法?
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD> <BODY>
<div id="divProductENDesc">
<iframe src="bb.html" width="100%" height="800" scrolling="Auto" frameborder="0" id="iProductENDesc" border=0></iframe>
</div> <INPUT TYPE="button" VALUE="调用iframe页面中的方法" ONCLICK="test()"><script type="text/javascript">
function test(){
var t=document.frames["iProductENDesc"];
t.test();
}</script> </BODY>
</HTML>bb页面<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0"> </HEAD> <BODY>
<table border="0" cellspacing="0" cellpadding="0" id="idTable">
<tr><td>
<input type="text" id="tt" name="tt" value="1" />
<input type="text" value="2"/></td></tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
function test(){
alert("我是iframe页面中的方法");
}
//-->
</SCRIPT>
</BODY>
</HTML>
框架里面的方法定义是function SetHtml(html){}
document.frames["iProductENDesc"]获取到了iframe的对象,而test()这个方法就是iframe内页上的,至于要调用什么方法,还用我告诉你么?
我的这么写没用啊 。这个是我框架里面的页面代码<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>产品编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="fckeditor.js"></script>
<script type="text/javascript">
/// 获取HTML源码代码
function GetHtml() {
var oEditor = FCKeditorAPI.GetInstance( 'FCKeditor1' );
if (null == oEditor)
{
return "";
}
else
{
return oEditor.GetXHTML();
}
}
///设置HTML源码
function SetHtml(html) {
var oEditor = FCKeditorAPI.GetInstance( 'FCKeditor1' );
if (null != oEditor)
{
return oEditor.SetData(html);
}
}
window.onerror=function(){return true;}
</script></head>
<body style="margin:0 0 0 0;">
<form action="" method="post" target="_blank">
<script type="text/javascript">
var oFCKeditor = new FCKeditor( 'FCKeditor1' );
//oFCKeditor.BasePath = sBasePath ;
oFCKeditor.BasePath = '';
oFCKeditor.Height = '100%' ;
oFCKeditor.ToolbarSet = "Custom";
//oFCKeditor.Value = '<p>This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.<\/p>' ;
oFCKeditor.Create();
</script>
</form>
</body>
</html>
var oEditor = FCKeditorAPI.GetInstance( 'FCKeditor1' );
//是window.frames["frameName"],不是这里的editor
你的editor应该放在了一个iframe中,你取iframe就可以了。不要搞FCKeditor1
document.getElementById("iProductENDesc").contentWindow.SetHtml()
这个是我框架里面引用的html的源代码 ,我现在要做的是想在父页面调用这个页面的SetHtml(html)方法
但是不管我怎么做,都不能设置成功
这句话会报Custom不存在错误,去掉这句话,在我机器上毫无问题,可以设置iframe内页中多媒体编辑框中的值!