New to Kendo UI for jQueryStart a free 30-day trial

Post to the Iframe Content of the Window

Environment

ProductProgress® Kendo UI® Window for jQuery
Operating SystemWindows 10 64bit
Visual Studio VersionVisual Studio 2017
Preferred LanguageJavaScript

Description

How can I post to the iframe content of the Kendo UI Window?

Solution

The example below demonstrates how to achieve the desired scenario.

    <button id="refresh">Post content to iframe</button>
    <script>
      $("#refresh").kendoButton({
        themeColor:"primary",
        click:function(e) {
          e.preventDefault();
          var id = "target_iframe";
          var dialog = $("<div><iframe class='k-content-frame' name='" + id + "'></div>").kendoWindow({
            width: "615px",
            title: "Posting to iframe example",
            close: function() { this.destroy() },
            iframe: true
          });
          dialog.data("kendoWindow").center().open();
          $("<form />", {
            action: "http://www.example.com/",
            method: "post",
            target: id
          })
            .hide().appendTo("body")
          // add any data
            .append("<input name='foo' />").find("[name=foo]").val("bar").end()
            .submit().remove();
        }
      })
    </script>

See Also