This is a migrated thread and some comments may be shown as answers.
browser scrolls to top of page on window.center().open()
1 Answer 24 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bill
Top achievements
Rank 1
Bill asked on 16 Nov 2011, 06:20 AM
This happens on IE9, FF6, and Chome. The position of the window is in the correctly centered horizontally and is placed vertically in the right location. However, the browser scrolls to the top of the page after the window is displayed. I am reusing a single telerik window for multiple purposes (iframes).
 function OpenImageWin(id, action) 
{         $("#ImageWin .t-window-content").html("");          
            var window = $("#ImageWin").data("tWindow");          
            var url;          
            var windowElement = $('#ImageWin').data('tWindow').element;          
        switch (action) 
{              case "Create":
                      url = '<iframe src="<%= Url.Action("Create", "Model" new { Id = ViewData["Id"]}) %>" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>';                                        
                      $(windowElement).find(".t-content").width(400).height(250); 
                      break;              
                case "Edit":                  
                     url = '<iframe src="<%= Url.Action("Edit", "Model", new { Id = "xid" }) %>" frameborder="0"  width="100%" height="100%" scrolling="no"></iframe>';
                      url = url.replace("xid", id)                  
                      $(windowElement).find(".t-content").width(800).height(600); 
                     break;              
                case "Delete":                  
                     url = '<iframe src="<%= Url.Action("Delete", "Model", new { Id = "xid" }) %>" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>';
                      url = url.replace("xid", id)
                      $(windowElement).find(".t-content").width(800).height(600);                   
                      break;
            }           
    $("#ImageWin .t-window-content").html(url);
    window.center().open();
}

1 Answer, 1 is accepted

Sort by
0
Bill
Top achievements
Rank 1
answered on 18 Nov 2011, 05:00 AM

seems to be unrelated. fix is not using an <a> tag like using a button or adding return false to the onclick event

<a href="#" onclick="OpenImageWin(<%: item.ImageId%>, 'Details'); return false">Details</a> 

Tags
Window
Asked by
Bill
Top achievements
Rank 1
Answers by
Bill
Top achievements
Rank 1
Share this question
or