Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Please help me with the code to redirection to a particular section of a page .

I am done with redirection to target page but what I want is to redirect to particular <div> of the page .

user-image
Question added by Rana Alnajjar , Web developer , Lebcards
Date Posted: 2015/05/26
Manal Abuelazaem
by Manal Abuelazaem , Application Developer and Owner , ManalSoft

You can simply use the anchor tag to point to specific section id .. eg:

 

First: You add this code to the section on the page you want to your link to jump to:

<a id="section1">Section1 title</a >

 

Second: You point your hyperlink to the id of that section preceded by a hash mark (#):

<a href="#section1">my link to section1</a >

or

 

if you want to link a page in site1 to a specific are in a page in site2 use:

<a href="http://www.site2.com/mypage.html#section1">Go to section1 in the2nd site</a >

 

Using javascript is not a good choice unless it is really needed because it will add more complexity and slow the page while there already a simple specific HTML tag.

You can do it in two ways.

1) [via Javascript (+jQuery)]

<ahref="#"id="home">home</a> $('#home').click(function(){ $(document).scrollTop(100) // any value you need });

2) [via pure HTML]

<ahref="#home_section">home</a><sectionid="home_section"></section>

More Questions Like This