簡體   English   中英

添加動態內容后跳轉到頁面上的位置

[英]Jumping to Position on page after Dynamic content added

我使用ajax將內容動態添加到我的網站,但是我希望頁面跳轉到已添加的內容,但是我無法讓我工作。

這是我用來添加內容並跳轉位置的鏈接。

<a href="javascript:ajaxpage('/console/new_message_profile.php', 'message_area');" onclick="window.scrollTo(0, 2000);">

為動態生成的元素指定一個id ,然后

$("#idofdynamicelement")[0].scrollIntoView( true );
// O to make sure its the first item if multiple found
// true to indicate the top position

似乎您通過使用window.scrollTo(0,2000);將頁面滾動到了其底部。 我已經在服務器上嘗試了您的代碼,但效果很好。 您能提供更多細節嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM