请问怎么在iframe里面插入一个字符?

zy8133 2003-10-15 10:32:46
一个javascript函数,就是要在iframe里面插入一个字符 ,可是老是插入在首行第一个位置,请大家指教
function insertLetter(char )//插入特殊字符
{
//alert(char);
var letterStr=char;
newiframe.document.body.innerHTML=letterStr;

var sel=newiframe.document.body.createTextRange( );
sel.select();

newiframe.document.execCommand('Copy');
myEditor.focus();//我觉得就是这里写错了吧,怎么能把我想插入的字符写到编辑文字时的光标所在处?
myEditor.document.execCommand('Paste');
}
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
asshead1 2004-02-19
  • 打赏
  • 举报
回复
iframe中如果是有效页面,字符就不能插入了,“拒绝访问”!
kingdomzhf 2003-10-15
  • 打赏
  • 举报
回复
up
nolonely 2003-10-15
  • 打赏
  • 举报
回复
<iframe name=demo></iframe>
<script language="JavaScript">
<!--
demo.document.designMode="on"
function a(){
demo.focus()
demo.document.selection.createRange().pasteHTML("hehe")
}
//-->
</script>
<input type="submit" onclick="a()">
zhfkiller 2003-10-15
  • 打赏
  • 举报
回复
<html>

<head>
<title>New Page 2</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<script>

</script>
</head>

<iframe id=pp src="new_page_2.htm">
</iframe>
<input type=button onclick="document.all('pp').contentWindow.document.body.insertAdjacentText('afterBegin','a')" value="insert text">
</html>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧