Firefox "jumps" when using UpdatePanel and SetFocus in an <iframe> (asp.net)
<p>I have the problem that Firefox "jumps" (moves the scrollbar to the top) if I use an UpdatePanel together with the SetFocus function inside an iframe. I'll show this by posting the code:</p>

<p>First of all the HTML of the webform:</p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
    &lt;/asp:ScriptManager&gt;
    &lt;div&gt;
        &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
            &lt;ContentTemplate&gt;
                &lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"&gt;
                    &lt;asp:ListItem&gt;1&lt;/asp:ListItem&gt;
                    &lt;asp:ListItem&gt;2&lt;/asp:ListItem&gt;
                    &lt;asp:ListItem&gt;3&lt;/asp:ListItem&gt;
                    &lt;asp:ListItem&gt;4&lt;/asp:ListItem&gt;
                    &lt;asp:ListItem&gt;5&lt;/asp:ListItem&gt;
                &lt;/asp:DropDownList&gt;
                &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
            &lt;/ContentTemplate&gt;
        &lt;/asp:UpdatePanel&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Now the codebehind to that form (it has no functions except an empty page_load and this one):</p>

<pre><code> protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label1.Text = DropDownList1.SelectedIndex.ToString();
            SetFocus(DropDownList1);
        }
</code></pre>

<p>OK, this form is hosted inside a barebone HTML page using an iframe. Here is the HTML host page:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
        bla bla bla
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;iframe src="WebForm1.aspx" style="height: 1263px; width: 1254px"&gt;&lt;/iframe&gt;
    &lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>I added the br elements because you need to have scroll bars to see the effect. Now if you scroll down in the host page and chose a value in the dropdownlist in the iframe in Internet Explorer, the Label gets updated without any problems and the dropdownlist gets the focus.</p>

<p>Now try the same in Firefox - everything works too, but you get the annoying effect that firefox scrolls the html host page to the top again!</p>

<p>I tried it with even bigger pages and multiple iframes, and it seems to scroll to the beginning of the one iframe in which you have chosen the value in the dropdownlist. Safari (and I guess Chrome) has the same behavior. Opera doesn't do this annoying "jump" (same with IE).</p>

<p>What is the problem here?</p>
