Mình có dùng 1 script sau:
Mã:
<script type="text/javascript">
        window.onload = function scroll(elID) {
        document.getElementById("main_content").scrollIntoView(true);
    };
    </script>
Khi m load trang web thì mạc định nó hiển thì trang web ở thẻ div có id là "main_content".
Nhưng giờ m thay đổi cách hiển thị:
- Khi vào trang chủ thì vẫn bình thường,nhưng khi nhấn vào 1 link liên kết VD:"chi-tiet.aspx?ID=1" thì nó mói di chuyển đến cái div id="main_content".để ng dùng k phải kéo xuóng dứoi để xem bài viết.
Code m thủ trong pageload:
Mã:
if (Request.QueryString["ID"] != null)
        {

            string sScript = "";
            sScript += "<script type='text/javascript'>)";
            sScript += "window.onload = function scroll() {";
            sScript += "document.getElementById('main_content').scrollIntoView(true);";
            sScript += "};";
            sScript += "</script>";
            Page.ClientScript.RegisterOnSubmitStatement(this.GetType(),
                    "ConfirmSubmit", sScript);
            //Page.ClientScript.RegisterStartupScript(Page.GetType(), "ScriptKey", sScript, true);

        }
Nhưng không dc!
Các bạn xem nó sai hay cần sửa chỗ nào!
và nếu bạn nào có cách khác thì giup mình!
Thanks!
@.Đã xong !Close topic