Jump to content

Clicked link jumps back to top of page


bytesize

Recommended Posts

<script type="text/javascript">
   function toggleInteractContainers(x) {
	if ($('#'+x).is(":hidden")) {
		$('#'+x).slideDown(200);
	} else {
		$('#'+x).hide();
	}
	$('.interactContainers').hide();
   }
</script>

<?php
 $interactionBox = '<div class="interactionLinksDiv">
  <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\''.$show['wb_memberid'].'\');">Send Request</a>
  </div>';
 echo $interactionBox;
?>

<div class="interactContainers" id="<?php echo $show['wb_memberid']; ?>">
  <a href="users/add?add=<?php echo $show['code']; ?>">Yes</a>
  <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('<?php echo $show['wb_memberid']; ?>');" title="Close">No</a>
</div>

When scrolled down to the "Yes" link and it is clicked, the page jumps up to the top of the browser. If "No" is clicked, the page does not move, which is the effect I'm looking for. How can I stop the page from jumping to the top?

 

I have tried using "#", onclick, and onmousedown within the "Yes" href to no avail. Anyone?

Link to comment
https://forums.phpfreaks.com/topic/276779-clicked-link-jumps-back-to-top-of-page/
Share on other sites

Your yes link actually sends you to a new page. The no one stays on the same page and goes nowhere. That is exactly how you have coded it. If you want the yes link to go to a new page AND scroll down to an anchor, that page needs to have the anchor on it, then you need to add it in the end of the link.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.