PDA

View Full Version : anchor link not working in javascript



mutago
05-25-2014, 02:33 PM
i want to embed a clickable anchor links in the code below.
eg.

'<a href="users.html?id=' + user.id + '"></a>'

how do i achieve this in the line of code below

+"<td>"+user.id+"</td>"





<script type="text/javascript">


var newRow =
"<tr>"
+"<td>"+user.id+"</td>"
+"<td>"+user.topic+"</td>"
+"<td>"+user.view+"</td>"
+"<td>"+user.reply+"</td>"
+"<td>"+user.datetime+"</td>"
+"</tr>" ;
>

jscheuer1
05-26-2014, 05:47 AM
An anchor link (whether created by javascript or hard coded into HTML) must be to a named anchor (whether created by javascript or hard coded into HTML). For example with an anchor link like:


<a href="somepage.htm#topic12">Topic 12</a>

That would take you to somepage.htm and once there look for:


<a name="topic12"></a>

If it finds that, it will scroll that named anchor to the top of the window or as close to the top of the window as it can get if that named anchor isn't already at the top of the window or as close to the top of the window as it can get.