[英]Replacing entire page with ajax response from a frame
I have a page with frames. 我有一个带有框架的页面。 In one frame a user's action can cause an ajax request to be sent.
在一个帧中,用户的操作可能导致发送ajax请求。 The response contains a complete new page and I want to replace the existing page with the response.
响应包含一个完整的新页面,我想用响应替换现有页面。 My problem is that when I try and do that the new content is rendered within the frame the request originated from.
我的问题是,当我尝试执行此操作时,新内容将在请求所源自的框架内呈现。 How can I replace the entire page and not just the frame?
如何替换整个页面而不仅仅是框架?
I've tried: 我试过了:
document.open();
document.write(response);
document.close();
and: 和:
var newDoc = document.open("text/html", "replace");
newDoc.write(response);
newDoc.close();
But I got the same undesirable results from both. 但是我从两者中得到了相同的不良结果。
I can't check right now, but assuming: 我现在无法检查,但假设:
You may try the following code: 您可以尝试以下代码:
document.parent.body.innerHTML = response;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.