0

)

I am using KENDO UI with IFRAME and I want to display an alert when the user clicks to close his WEB browser when the IFRAME is active with KENDO.

So I specify that I want to see the alert is triggered only if the IFRAME is active

Here is my code :

        <button id="refresh" class="k-button k-primary" title="START">START</button>
    <div id="messageDialog"></div>
        <script>
           var isClosed = false;
          $("#refresh").click(function(e) {
            e.preventDefault();

            var id = "target_iframe";

            var dialog = $("<div><iframe class='k-content-frame' name='" + id + "'></div>").kendoWindow({
             title: "test",
              close: function() { this.destroy() },
              iframe: true,
              close: function(e) {
          if(!isClosed) {
            $("#messageDialog").kendoDialog({
             title: "test",
              content: "Exit ?",
              visible: false,
               show: function() {
                e.preventDefault();
              },
              actions: [{
                  text: "Exit",
                  action: function(e){
                    setTimeout(function() {
                      isClosed = true;
                      $("#target_iframe").data("kendoWindow").close();
                    }, 200);
                  },
                  primary: true
              },{
                  text: "Cancel"
              }]
            }).data("kendoDialog").open();
          }
        },
        deactivate: function() {
          isClosed = false;
        }
            });

            dialog.data("kendoWindow").center().open();


            $("<form />", {
                action: "https://www.mywebsite.com/",
                method: "post",
                target: id
            })
                .hide().appendTo("body")
                   // add any data
                  .append("<input name='foo' />").find("[name=foo]").val("bar").end()
                .submit().remove();
          });


    </script>

Thank you in advance :)

Julia75007
  • 21
  • 3

0 Answers0