Jump to content

Clicked link jumps back to top of page


Go to solution Solved by 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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.