[CLOSED] [1.0] IE8 blocks window.open when inside a DirectMethod

  1. #1

    [CLOSED] [1.0] IE8 blocks window.open when inside a DirectMethod

    Hi,

    I am having an issue with DirectMethod that calls window.open. Consider the code below. The first link works OK, window gets opened. But if I use a DirectMethod and call window.open, IE blocks it. Please let me know if theres a work around for this issue.

    
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
            }
        }
    
        [DirectMethod]
        public static string GetURL()
        {
            return "http://google.com";
        }
        
        
        
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Simple Array Grid - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />    
    
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" />
    
        <script type="text/javascript">
    
            function openYahoo() {
                var width = 800;
                var height = 600;
                var left = Math.floor((screen.availWidth - width) / 2);
                var top = Math.floor((screen.availHeight - height) / 2);
                var windowFeatures = "width=" + width + ",height=" + height +
                ",menubar=no,toolbar=no,scrollbars=no,resizable=no," +
                "left=" + left + ",top=" + top +
                "screenX=" + left + ",screenY=" + top;
                child1 = window.open("http://yahoo.com", "winYahoo", windowFeatures);
    
            }
    
            function openGoogle() {
                Ext.net.DirectMethods.GetURL({ success: function (result) {
                    var width = 800;
                    var height = 600;
                    var left = Math.floor((screen.availWidth - width) / 2);
                    var top = Math.floor((screen.availHeight - height) / 2);
                    var windowFeatures = "width=" + width + ",height=" + height +
                ",menubar=no,toolbar=no,scrollbars=no,resizable=no," +
                "left=" + left + ",top=" + top +
                "screenX=" + left + ",screenY=" + top;
                    child1 = window.open(result, "winGoogle", windowFeatures);
                } });
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        <a href="#" onclick="openYahoo(); "> Open Yahoo</a>
        <br />
        <a href="#" onclick="openGoogle(); ">Open Google</a>
    </body>
    </html>
    Looking forward to your response.
    Last edited by Daniil; Jun 20, 2011 at 4:38 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Well, yes, it's default security settings. The same is in FF.

    I think the one way to avoid this warning message is changing respective settings in IE. And, certainly, we can't to change it either via JavaScript or code behind.

    I can suggest you to use <ext:Window> instead of window.open().

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        [DirectMethod]
        public static string GetURL()
        {
            return "http://google.com";
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
     
        <script type="text/javascript">
            var openYahoo = function () {
                openLink("http://yahoo.com", "Yahoo");
    
            }
     
            var openGoogle = function () {
                Ext.net.DirectMethods.GetURL({ 
                    success: function (result) {
                        openLink(result, "Google");
                    } 
                });
            }
            
            var openLink = function openLink(url, title) {
                Window1.load(url);
                Window1.setTitle(title);
                Window1.show();
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:Window 
            ID="Window1" 
            runat="server" 
            Hidden="true" 
            Width="400" 
            Height="400" />
         
        <a href="#" onclick="openYahoo(); "> Open Yahoo</a>
        <br />
        <a href="#" onclick="openGoogle(); ">Open Google</a>
    </body>
    </html>
  3. #3
    Hi Daniil,

    Thank you for the response. Please mark as solved.

Similar Threads

  1. [CLOSED] DirectMethod is not working inside window.onbeforeunload for Firefox
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 14, 2011, 10:16 AM
  2. Replies: 1
    Last Post: Nov 11, 2010, 1:04 AM
  3. Replies: 9
    Last Post: Oct 07, 2010, 6:27 PM
  4. Replies: 1
    Last Post: Mar 09, 2010, 10:57 AM
  5. [OPEN] HtmlEditor inside ext:window
    By methode in forum Bugs
    Replies: 10
    Last Post: Jan 18, 2009, 2:59 AM

Posting Permissions