Page 1 of 1

Anchor tag does not work [solved]

Posted: Mon Jan 09, 2006 5:45 am
by raghavan20
I have a source page from which I want to go to some selected anchors within a target file. But I am not able to do it... why?
code for source file

Code: Select all

<html>
<body>
	<a href = "targetHtml.html#1" >Go to first div</a><br />
	<a href = "targetHtml.html#1" >Go to second div</a><br />
	<a href = "targetHtml.html#1" >Go to third div</a><br />
</body>
</html>
code for target file

Code: Select all

<html>
<body>
	<a name = "1" />
	<div>First Div</div>
	<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br 

/><br /><br /><br />

	<a name = "2" />
	<div>Second Div</div>
	<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br 

/><br /><br /><br />

	<a name = "3" />
	<div>Third Div</div>
	<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br 

/><br /><br /><br />

</body>
</html>

Posted: Mon Jan 09, 2006 7:20 am
by jayshields
Change your target file to this:

Code: Select all

<html> 
<body> 
   <a name = "1"> 
   <div>First Div</div> 
   </a>
   <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br 

/><br /><br /><br /> 

   <a name = "2"> 
   <div>Second Div</div> 
   </a>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br 

/><br /><br /><br /> 

   <a name = "3"> 
   <div>Third Div</div> 
   </a>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br 

/><br /><br /><br /> 

</body> 
</html>

Posted: Mon Jan 09, 2006 8:27 am
by raghavan20
The problem was not putting text inside <a> but in the sourceHtml file I by mistake put anchor tags with the same value 1 for all of them...

Here is the correct source code for sourceHtml.html

Code: Select all

<html> 
<body> 
   <a href = "targetHtml.html#1" >Go to first div</a><br /> 
   <a href = "targetHtml.html#2" >Go to second div</a><br /> 
   <a href = "targetHtml.html#3" >Go to third div</a><br /> 
</body> 
</html>