Requirement:
Show a particular section on load of the page. only when query string present in URL
for that page and where div id- showsection exist.
Solution:
if(document.getElementById("showsection") != null)
{
var str = document.URL.split('?')[1];
if(str != undefined && str.length>0)
{
jQuery("html, body").animate({scrollTop:jQuery("#showsection").offset().top},1000);
}
}
In HTML page:
<div id="showsection"></div>
<div id="test">
test document
</div>
Description:
By placing javascript code in document ready, whole page will be scrolled up and show "test".
You do not have to put anything inside "showsection" div
No comments:
Post a Comment