Page done loading scroll to top

When the page is done loading, I want to scroll to the top of the page.

Is there Javascript for this?

Please provide source code.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
dejaanbuConnect With a Mentor Commented:

will it be a soln for u?

Page.MaintainScrollPositionOnPostBack = True
0
 
edemcsConnect With a Mentor Commented:
Yes.  You can place Javascript as the last line in the html form.

<script type="text/javascript" language="javascript">
window.scrollBy(0,0);
</script>
0
 
Tom KnowltonWeb developerAuthor Commented:
What if the page is a content page with a master page in asp.net?

Where does the javascript go?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Tom KnowltonWeb developerAuthor Commented:
I should mention that what seems to be causing this problem is an iframe.

When the src for the iframe changes to another URL....the entire page scrolls down.
0
 
edemcsCommented:
Can you share your code?
0
 
Tom KnowltonWeb developerAuthor Commented:
>>>Page.MaintainScrollPositionOnPostBack = True

Did not change the behavior.


Here is my code:

Master Page:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="TCSSite.Master.cs" Inherits="Campus_Webstore.SiteWideMaster.TCSSiteUCONN" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/UserControls/TopCart.ascx" TagName="TopCart" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/usertop.ascx" TagName="usertop" TagPrefix="uc2" %>
<%@ Register Src="~/UserControls/Catalogs.ascx" TagName="Catalogs" TagPrefix="uc3" %>
<%@ Register src="../../UserControls/HorizMenu.ascx" tagname="HorizMenu" tagprefix="uc5" %>
<%@ Register src="../../UserControls/AccordionNav.ascx" tagname="AccordionNav" tagprefix="uc4" %>
<%@ Register Src="~/UserControls/gentoplogin.ascx" TagName="Login1" TagPrefix="uc10" %>
<%@ Register Src="~/UserControls/HuskyFooter.ascx" TagName="HuskyFooter" TagPrefix="uc11" %>
<%@ Register assembly="Campus Webstore" namespace="Campus_Webstore" tagprefix="cc1" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head id="Head1" runat="server">



<title>UConn Co-op Husky Shop</title>
    <link href="~/Scripts/jquery.superbox.css" rel="stylesheet" type="text/css" />
    <link href="~/App_Themes/uconn/cws2.css" rel="stylesheet" type="text/css" />
    <link href="~/App_Themes/uconn/uconn.css" rel="stylesheet" type="text/css" />
    <link href="~/Scripts/allclients.css" rel="stylesheet" type="text/css" />
    <link href="../../App_Themes/uconn/addoredit_control.css" rel="stylesheet" type="text/css" />
    <link href="../../App_Themes/uconn/addoredit_popupstyling.css" rel="stylesheet" type="text/css" />
    <link href="../../App_Themes/uconn/shippingmethodstyling.css" rel="stylesheet" type="text/css" />
    <link href="../../App_Themes/uconn/orderdonestyling.css" rel="stylesheet" type="text/css" />
    <link href="../../App_Themes/uconn/securepaymentpagestyling.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-1.4.1.js"></script>
    <script src="../../Scripts/husky_top_menu.js" type="text/javascript"></script>
    <script src="../../EFUImageUploader/efu-js/easyflashuploader.js" type="text/javascript"></script>
    <script src="../../EFUImageUploader/efu-js/language.en.js" type="text/javascript"></script>
    <link rel="SHORTCUT ICON" href="../../favicon.ico" />

    <%-- <link rel="shortcut icon" href="../App_Themes/SkinFile/Images/favicon.ico" type="image/vnd.microsoft.icon" />--%>

<!-- ******** BEGIN LIKNO WEB ACCORDION CODE FOR likno_accordion_project ******** -->
<%--<script type="text/javascript">    
var lwacLinkedBy = "LiknoWebAccordion [1]", lwacName = "likno_accordion_project", lwacBN = "126";
</script>
<script charset="UTF-8" src="../../Scripts/likno_accordion_project.js" type="text/javascript"></script>--%>
<!-- ******** END LIKNO WEB ACCORDION CODE FOR likno_accordion_project ******** -->


<script type="text/javascript">

    window.scroll(0, 0);

    function CheckForFrameChange()
    {
        var theframe = document.getElementById("ccinfo");

        strURL = theframe.src;
        //setup a pointer to the begining of the /photos/ part of the string
        var hasit = strURL.indexOf('ElementPSResults');
        if (hasit > 0)
        {
            var theHTML = document.getElementById("ccinfo").contentWindow.document.body.innerHTML;
            if (theHTML.indexOf('veryobviousSuccess') > 0)
            {
                alert("Suceess was found");
            }
        }
        else
        {
           // CheckForFrameChange();
        }
    }
</script>





</head>
<body id="bodytaguconn" runat="server">
    <form id="mainbodyformuconn" runat="server">
    <ajaxToolkit:ToolkitScriptManager runat="server" ID="toolKit" AllowCustomErrorsRedirect="true"
        EnablePartialRendering="true">
        <Scripts>
            <%-- <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAim5Ru7zlC5LJzi3w0XqvXxTNtfGCkjY40i7thHFIqUc19l7sbRSfcvST6GfqHG6636f3bKKwrbkUbA"></script>
			<script language="javascript" type="text/javascript">
			//<![CDATA[
				google.load("jquery", "1");
			//]]>
			</script>
		   
            --%>
            <atlas:ScriptReference Path="~/scripts/thickbox.js" />
            <atlas:ScriptReference Path="~/scripts/contact.js" />
        </Scripts>
    </ajaxToolkit:ToolkitScriptManager>



<div id="W" class="W">
<div id="C" class="C">
<div id="C1" class="C1"></div><%--end div c1--%>
<div id="O" class="O">
<div id="S" class="S"><uc10:Login1 ID="Login1" runat="server" /></div><%--end div s--%>
</div><%--end div o--%>
<div id="Y" class="Y">
<div id="V" class="V"></div><%--end div v--%>
<div id="P" class="P">
<cc1:themeawareimage ID="ThemeAwareImage2" runat="server" 
        ImageUrl="new_header_angled2.png" />
</div><%--end div p--%>
<div id="U" class="U">


<div id="T" class="T"><object id="searchtcsdatc" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0"
            width="200" height="22" align="left">
            <param name="allowScriptAccess" value="always" />
            <param name="allowFullScreen" value="false" />
            <param name="movie" value="/searchtcs.swf" />
            <param name="quality" value="high" />
            <param name="bgcolor" value="#ffffff" />
            <param name="wmode" value="transparent" />
            <embed src="/searchtcs.swf" id="searchtcsdatcembed" quality="high" bgcolor="#ffffff"
            width="200" height="22" name="searchtcsdatcsname" align="left" allowscriptaccess="always"
            allowfullscreen="false" wmode="transparent" type="application/x-shockwave-flash"
            pluginspage="https://www.adobe.com/go/getflashplayer" />
</object>
</div><%--end div t--%>
<div id="X" class="X"><uc1:TopCart ID="TopCartHusky" runat="server" /></div><%-- end div x --%>
</div><%--end div u--%>
</div><%--end div y--%>


<div id="Z" class="Z">
<div id="N" class="N">
</div>
<%--end div n--%>
<div id="R" class="R">
<uc5:HorizMenu ID="HorizMenu1" runat="server" />
</div><%--end div r--%>
</div><%--end div z--%>

</div><%--end div c--%>
<div id="A1" class="A1">
<div id="E" class="E">

<div id="F" class="F"><cc1:themeawareimage ID="husky_dog" 
        runat="server" ImageUrl="husky-dog.png" /></div><%--end div f--%>
<div id="G" class="G">
<uc3:Catalogs runat="server" ID="Catalogs1" />
</div><%--end div g--%>
</div><%--end div e--%>
<div id="D" class="D">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>    
</div><%--end div d--%>
<div id="H" class="H">
<div id="I" class="I"></div><%--end div i--%>
<div id="B1" class="B1">
<div id="J" class="J"><uc11:HuskyFooter ID="HF" runat="server" /></div><%--end div j--%>
<div id="K" class="K">




<!-- BEGIN FOOTER | DO NOT EDIT THIS AREA -->
<%--<div id="footer">
<div class="content">
<div class="footer_r">
<a href="http://bookstore.uconn.edu/">UConn Co-op Bookstore</a> &nbsp;·&nbsp;Phone:
(860) 486-3537<br />
Questions: <a href="mailto:asktheco-op@bookstore.uconn.edu">Co-op Help/Info</a><br />
Webmaster: michael.jean@uconn.edu<br />
</div>
<div class="footer_l">
<br />
Powered by:<br />
<a href="http://total-computing.com/">
Total Computing</a><br />
</div>
</div>
</div>--%>
<!-- END FOOTER -->




</div><%--end div k--%>
</div><%--end div b1--%>
</div><%--end div h--%>
</div><%--end div a1--%>
</div><%--end div w--%>


    </form>


</body>
</html>

Open in new window



content page:
<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="SecureOrderForm.aspx.cs" Inherits="Campus_Webstore.SecureOrderForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<div id="AEPS" class="AEPS">



<div id="BEPS" class="BEPS">

<div id="CEPS" class="CEPS">


</div><%--end of div CEPS--%>


<div id="DEPS" class="DEPS">
Secure Order Form
</div><%--end of div DEPS--%>

<div id="GEPS" class="GEPS"></div><%--end of div GEPS--%>

</div><%--end of div BEPS--%>



<div id="EEPS" class="EEPS">


<div id="HEPS" class="HEPS">
<iframe id="ccinfo" frameborder="0" style="border-width:0px;background-color:#fff;width:770px;height:400px;overflow:hidden;" runat="server" src="Blank.aspx?show=no"></iframe>                                               
</div><%--end of div HEPS--%>

<div id="FEPS" class="FEPS">
<asp:Button ID="ButtonElementDoneCheck" runat="server" Text="View Order Details" 
        Height="22px" onclick="ButtonElementDoneCheck_Click" />    
</div><%--end of div FEPS--%>

</div><%--end of div EEPS--%>



</div><%--end of div AEPS--%>




</asp:Content>

Open in new window





ccinfo is the iframe.
0
 
Tom KnowltonWeb developerAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.