New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Using iframe
Updated over 6 months ago
You can force the Window to display its content in an <iframe> element by using the Iframe(true) configuration method. In this case, the Window content will be loaded into an HTML page that is embedded into the current HTML page.
- Loading HTML fragments (partial content) inside an
iframeis not correct. Like standard web pages,iframepages have to include aDOCTYPE,html,head, andbodytags.- Avoid using an
iframeon iOS devices because iOS devices do not supportiframescrolling and always expand to match the content.
The following example demonstrates how to access the window and document objects inside the iframe. To achieve this, the nested page has to belong to the same domain as the main page. The iframe is accessed through the element of the Window.
Razor
@(Html.Kendo().Window()
.Name("window")
.Title("Iframe Window")
.Iframe(true)
.LoadContentFrom("Content", "Home")
)
<script>
$(function() {
var windowElement = $("#window");
var iframeDomElement = windowElement.children("iframe")[0];
var iframeWindowObject = iframeDomElement.contentWindow;
var iframeDocumentObject = iframeDomElement.contentDocument;
// which is equivalent to
// var iframeDocumentObject = iframeWindowObject.document;
var iframejQuery = iframeWindowObject.$; // if jQuery is registered inside the iframe page, of course
});
</script>