关闭旧iframe后创建新iframe
creating new iframe after closing old one
我有一个通过ajax发送数据到php文件的字段Iframe。如果它是成功的,我关闭(它正在工作)iframe,并创建一个新的信息(不工作)。那么问题来了:如何关闭旧框架并打开另一个框架?
这是一个ajax函数,它可以工作,但不会打开一个新的iframe
$.ajax({
type: "POST",
url: "sign.php",
data: {name : name,
data: canvasData
},
success: function () {
//frame_activation(); //if it will be here it will open iframe inside the old one iframe.
alert('done');
close_frame ();
$(body).html(argument[0]);
//windows.top.frame_activation();
frame_activation(); // does't work
}
});
所以结果是-旧iframe发送信息并关闭它,但不打开一个新的iframe。
框架激活:
function frame_activation() {
//document.getElementById('bg_frame').style.visibility = 'visible';
reg = document.createElement('iframe');
document.body.appendChild(reg);
reg.id = 'iframe';
reg.src = 'activate.html';
reg.style.width='600px';
reg.style.height='200px';
position_frame(reg);
reg.style.border='solid 5px #d4d4d4';
alert('here');
return false;
}
关闭iframe:
function close_frame () {
parent.document.getElementById('bg_frame').style.visibility = 'hidden';
var el = parent.document.getElementById('iframe');
el.style.display='none';
parent.document.body.removeChild(el);
return(false);
}
使用
字段创建第一个iframe的函数function frame_reg() {
document.getElementById('bg_frame').style.visibility = 'visible';
reg = document.createElement('iframe');
document.body.appendChild(reg);
reg.id = 'iframe';
reg.src = 'frame.html';
reg.style.width='640px';
reg.style.height='400px';
position_frame(reg);
reg.style.border='solid 5px #d4d4d4';
return false;
}
可以通过改变iframe的src来改变页面的显示。
这是使用Jquery的示例:$(document).ready(function () {
$("#btnMenu1").click(function () {
$("#myIframe").attr("src", "example.aspx");
});
});
相关文章:
- 使用jQuery从原始页面内容创建iframe
- 动态创建的iframe中的window.onerror在lne 0处给出脚本错误
- 谷歌索引iframe动态创建了什么
- 如何在不使用iframe或库的情况下创建剪切显示窗口区域
- 动态(重新)创建iframe内容不会重置Chrome中的JS对象
- 附加'沙箱'属性设置为动态创建的iframe以停止重定向
- 如何设置外部javascript创建的iframe的位置
- 如何在 iframe 中创建 HTML5 数据属性
- 创建使用 ajax 更新 iframe 的链接
- 如何在跨域中创建响应式iframe
- 如何创建iframe内容的书签
- 按日期为iframe创建一个HTML链接
- 如何从主框架获取对在iframe上创建的对象的引用
- 在Internet Explorer 8中的Iframe中创建TinyMCE时出现问题
- 为其他域的 iframe 创建内容
- Ajax Iframe 创建(Spotify widget):x 帧错误
- 使用 jquery 从 iframe 创建弹出窗口
- 为iFrame创建浮动水平滚动条
- ExtJs,从不同版本的iframe创建窗口,正确设置高度
- 为两个iframe创建公共卷轴