现在有一个父界面,用的是jquery easyui的lay-out框架。
每点击不同的按钮就会用js动态添加一个tab,每个tab中包含一个iframe页面var content = '<iframe name="1" scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>';问题是:怎么根据点击的按钮来给每个iframe页面赋值呢
iframe中的代码如下: <body>
<div class="div-margin-bottom" id="title">标题:<input id="caption" name="caption" style="width:400px;"/></div>
<p>内容:</p>
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
</textarea>
<p>
<input id="submit" type="button" value="Submit" onclick="test();"/>
</p>
</body>
每点击不同的按钮就会用js动态添加一个tab,每个tab中包含一个iframe页面var content = '<iframe name="1" scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>';问题是:怎么根据点击的按钮来给每个iframe页面赋值呢
iframe中的代码如下: <body>
<div class="div-margin-bottom" id="title">标题:<input id="caption" name="caption" style="width:400px;"/></div>
<p>内容:</p>
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
</textarea>
<p>
<input id="submit" type="button" value="Submit" onclick="test();"/>
</p>
</body>
你用Jquery先把content封装成JQuery对象,再用attr给属性赋值应该可以吧
对象转换直接用$(content)就可以了
var zdoc = document.frames[id].document;
zdoc.getElementById('caption').value = ...
就可以了
//已经加载完,这里赋值
}else{
//没有加载完,则每次加载状态改变时都判断一下
iframeWindow.document.onreadystatechange = function(){
if(iframeWindow.document.readyState == 'complete'){
//已经加载完,这里赋值
}
};
}
iframeWindow就是你取到的那个iframe页面的window对象。