免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2063 | 回复: 0
打印 上一主题 下一主题

如何往iframe文本编辑框中自动输入文本 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-27 11:36 |只看该作者 |倒序浏览
本帖最后由 小公猫 于 2012-03-27 12:44 编辑

我想写个程序,在一个页面的编辑器中输入文本后自动提交,文本编辑器和对应的HTML代码分别如下:
  1. <tr>
  2. <td></td>
  3. <td colspan="2"><div id="mess_div">
  4. <div class="rteDiv" id="rteDiv_id">
  5. <div class="bordered">
  6. <div class="rteBack" id="Buttons1_mess">
  7. <p class="rte_toolbar"> <span class="rte_button">
  8. <select name="select" id="formatblock_mess" onChange="selectFont('mess', this.id);">
  9. <option value="">[风格]</option>
  10. <option value="&lt;p&gt;">Paragraph &lt;p&gt;</option>
  11. <option value="&lt;h1&gt;">Heading 1 &lt;h1&gt;</option>
  12. <option value="&lt;h2&gt;">Heading 2 &lt;h2&gt;</option>
  13. <option value="&lt;h3&gt;">Heading 3 &lt;h3&gt;</option>
  14. <option value="&lt;h4&gt;">Heading 4 &lt;h4&gt;</option>
  15. <option value="&lt;h5&gt;">Heading 5 &lt;h5&gt;</option>
  16. <option value="&lt;h6&gt;">Heading 6 &lt;h6&gt;</option>
  17. <option value="&lt;address&gt;">Address &lt;ADDR&gt;</option>
  18. <option value="&lt;pre&gt;">Formatted &lt;pre&gt;</option>
  19. </select>
  20. </span> <span class="rte_button">
  21. <select name="select" id="fontname_mess" onChange="selectFont('mess', this.id)">
  22. <option value="Font" selected="selected">[字体]</option>
  23. <option value="Arial, Helvetica, sans-serif">Arial</option>
  24. <option value="Courier New, Courier, mono">Courier New</option>
  25. <option value="Times New Roman, Times, serif">Times New Roman</option>
  26. <option value="Verdana, Arial, Helvetica, sans-serif">Verdana</option>
  27. <option value="宋体">宋体</option>
  28. <option value="黑体">黑体</option>
  29. </select>
  30. </span> <span class="rte_button">
  31. <select name="select" id="fontsize_mess" onChange="selectFont('mess', this.id);" unselectable="on">
  32. <option value="Size">[大小]</option>
  33. <option value="1">1</option>
  34. <option value="2">2</option>
  35. <option value="3">3</option>
  36. <option value="4">4</option>
  37. <option value="5">5</option>
  38. <option value="6">6</option>
  39. <option value="7">7</option>
  40. </select>
  41. </span>
  42. </div>
  43. <div class="rteBack" id="Buttons2_mess">
  44. <p class="rte_toolbar"> <span class="rte_button"><img id="bold" class="rteImage" src="/rte/images/bold.gif" alt="Bold" title="粗体" onClick="rteCommand('mess', 'bold', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/italic.gif" alt="Italic" title="斜体" onClick="rteCommand('mess', 'italic', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/underline.gif" alt="Underline" title="下划线" onClick="rteCommand('mess', 'underline', '')" width="18"></span> <span class="rte_button"><img class="rteVertSep" src="/rte/images/blackdot.gif" alt="" border="0" height="18" width="2"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/left_just.gif" alt="Align Left" title="左对齐" onClick="rteCommand('mess', 'justifyleft', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/centre.gif" alt="Center" title="居中" onClick="rteCommand('mess', 'justifycenter', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/right_just.gif" alt="Align Right" title="右对齐" onClick="rteCommand('mess', 'justifyright', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/justifyfull.gif" alt="两端对齐" title="两端对齐" onClick="rteCommand('mess', 'justifyfull', '')" width="18"></span> <span class="rte_button"><img class="rteVertSep" src="/rte/images/blackdot.gif" alt="" border="0" height="18" width="2"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/hr.gif" alt="Horizontal Rule" title="水平线" onClick="rteCommand('mess', 'inserthorizontalrule', '')" width="18"></span> <span class="rte_button"><img class="rteVertSep" src="/rte/images/blackdot.gif" alt="" border="0" height="18" width="2"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/numbered_list.gif" alt="Ordered List" title="有序列表" onClick="rteCommand('mess', 'insertorderedlist', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/list.gif" alt="Unordered List" title="无序列表" onClick="rteCommand('mess', 'insertunorderedlist', '')" width="18"></span> <span class="rte_button"><img class="rteVertSep" src="/rte/images/blackdot.gif" alt="" border="0" height="18" width="2"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/outdent.gif" alt="Outdent" title="减小缩进" onClick="rteCommand('mess', 'outdent', '')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/indent.gif" alt="Indent" title="增大缩进" onClick="rteCommand('mess', 'indent', '')" width="18"></span> <span class="rte_button"><span id="forecolor_mess"><img class="rteImage" src="/rte/images/textcolor.gif" alt="Text Color" title="前景色" onClick="dlgColorPalette('mess', 'forecolor', '')" width="18"></span></span> <span class="rte_button"><span id="hilitecolor_mess"><img class="rteImage" src="/rte/images/bgcolor.gif" alt="Background Color" title="背景色" onClick="dlgColorPalette('mess', 'hilitecolor', '')" width="18"></span></span> <span class="rte_button"><img class="rteVertSep" src="/rte/images/blackdot.gif" alt="" border="0" height="18" width="2"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/hyperlink.gif" alt="Insert Link" title="插入链接" onClick="dlgInsertLink('mess', 'link')" width="18"></span> <span class="rte_button"><img class="rteImage" src="/rte/images/image.gif" alt="Add Image" title="插入图片" onClick="addImage('mess')" width="18"></span> <span class="rte_button"><span id="table_mess"><img class="rteImage" src="/rte/images/insert_table.gif" alt="Insert Table" title="插入表格" onClick="dlgInsertTable('mess', 'table', '')" width="18"></span></span> <span width="100%"></span> </p>
  45. </div>
  46. <iframe id="mess" name="mess" frameborder="0"></iframe>
  47. <p id="sedit">
  48. <input name="checkbox" type="checkbox" id="chkSrcmess" onClick="toggleHTMLSrc('mess',true);">
  49. &nbsp;
  50. <label for="chkSrcmess">源文件编辑</label>
  51. </p>
  52. <iframe id="cpmess" src="/rte/includes/palette.htm" marginwidth="0" marginheight="0" style="display: none; position: absolute;" height="104" scrolling="no" width="154"></iframe>
  53. <input id="hdnmess" name="hdnmess" value="" type="hidden">
  54. </div>
  55. </div>
  56. <textarea style="display:none; width: 606px; " name="text" id="text" rows="15" wrap="virtual" onFocus="set_event(1);" onBlur="set_event(0);" onKeyDown="return event.keyCode!=27;"></textarea>
  57. <textarea style="display:none; width: 606px; " id="replymsg" name="replymsg"></textarea>
  58. <script language="javascript">
  59. change_body() ;
  60. </script>
  61. </div></td>
  62. </tr>
复制代码
这个编辑框在一个iframe中:
<iframe id="mess" name="mess" frameborder="0"></iframe>
请问要怎么样插入文本?像TextBox一样。
我用的是Win32::IEAutomation模块,比如给用户名输入框输入文本:$ie_login->getTextBox('name:',"username")->SetValue('myname');
这个文本编辑器要怎么赋值?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP