将内容设置为iframe [英] Set contents to iframe

查看:96
本文介绍了将内容设置为iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function IsEdit(ID,i,companyId, companyType) {
       try {

           document.getElementById('hdnIsEdit').value = ID;
           document.getElementById('txtHistoryMessage' + ID).style.Width = "250" + "px";
           document.getElementById('txtHistoryMessage' + ID).style.Height = "250" + "px";
           document.getElementById('btnEdit' + ID).style.display = "none";

           jQuery.CcEditorPlugin($("#txtHistoryMessage" + ID), {
               style: "css/jquery.sceditor.default.min.css"
           });

           $('iframe')[1].contents().find('body')[0].innerHTML = document.getElementById('txtHistoryMessage' + (ID)).value; MatchHeights()
       }
       catch (ex) {
           alert(ex.Message());
       }
   }




需要将txtHistoryMessage的内容设置为页面




Need to set contents of txtHistoryMessage to the iframe1 of page

推荐答案

(" + ID),{ 样式:" });
("#txtHistoryMessage" + ID), { style: "css/jquery.sceditor.default.min.css" });


(' iframe')[ 1 ].contents().find(' body' span>)[ 0 ].innerHTML = document.getElementById(' ; MatchHeights() } 捕获(例如){ alert(ex.Message()); } }
('iframe')[1].contents().find('body')[0].innerHTML = document.getElementById('txtHistoryMessage' + (ID)).value; MatchHeights() } catch (ex) { alert(ex.Message()); } }




首先需要将txtHistoryMessage的内容设置为页面的iframe1




Need to set contents of txtHistoryMessage to the iframe1 of page


首先,除非您的iframe引用了同一域中的页面,否则由于相同起源政策.

否则,我看不到那里的代码有问题.
First off, unless your iframe is referring to a page on the same domain, you can''t, due to the Same Origin Policy.

Otherwise, I see no problem with the code you have there.


这篇关于将内容设置为iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆