Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    JavaScript


Page "jumping" Back To Top... How Do I Stop It?

I have a piece of javascript running about mid-section on a webpage. It's doing exactly what I want it to do, but when it runs it also "jumps" the page back to the top. That is, if I have my scroll bar half way down the page, when I click on the link and run this code it jumps me back to the top as if I'm visiting for the first time.

Any ideas on how to keep it on the same spot on the page while still executing the code?

Here is my code:

function changeOrderDetail(changeTo) {
if (changeTo == "guys") {
document.getElementById('orderDetail').style.backgroundImage = "url(images/subpage_odguysbg.jpg)";
} else {
document.getElementById('orderDetail').style.backgroundImage = "url(images/subpage_odgalsbg.jpg)";

View 8 Replies (Posted: Jan 26, 2006, 11:51)

Sponsored Links:

Related Forum Messages For JavaScript category:
Stop From Jumping To Top Of Page?
Is there anyway to stop the page 'jumping to the top' when using a link like the below?

<a href="#"

.. I just want it to stay in the same position on the page & not jump to the top of the page every time a link like that is clicked.

Posted: 09-11-2007, 02:24 AM

View 18 Replies!   View Related
JQuery :: Stop Page From Jumping To The Top?
i've made a menu for my website and i've used to jQuery to create a sub menu on the 'about' section.

the problem is when you click the button, the page jumps to the top.. which i don't want it to do. is there a way round this?

here's the javascript i'm using:

$(document).ready(function () {
$('li.aboutb').click(function () {

here's a link to the page in question: click me

Posted: 29-Mar-2011

View 3 Replies!   View Related
JQuery :: Stop Page From Jumping To The Top OnClick?
My question is, what do I need to do to stop a browser from jumping to the top of the page when a user clicks on a link which has a jquery function attached to it?So for exampleUser clicks on a link called "Older Stories"Once they do that, jquery will load in some content AJAX styleHowever, browser has jumped to the top of the page and we have to scroll back down again to see the content which has just been loaded in.I've tried putting a return statement in my code but it didn't do anythingHere's my code

var content = $("#ajax_content");


Posted: 26-Oct-2009

View 2 Replies!   View Related
Ajax :: Stop Onclick 'page Jumping'?
Can't seem to prevent the jump to top of page behavior. I've tried everything suggested here [URL]...What else could be done to stop onclick page jumps? Here's a snippet of the HTML and JS

<a href="javascript: return null;" onclick='javascript:getPosts("page=1&display=all"); return false;'>Everyone</a>
function getPosts(qry) {


Posted: Dec 17 09 at 19:31

View 9 Replies!   View Related
Stop Browser From Jumping To #name When Page Loads?
I have a form in a jQuery dialog box named "login". In JavaScript, I detect if "#login" is in the URL -- if so, it displays the login dialog box. In FF/Safari/Chrome it works fine, but in IE6/7 the browser page jumps down to the top of the form when the dialog box is displayed. I would like to prevent this from happening.I found what looked like an answer to my question here, which gives this example code: $('a.anchor').remove ().prependTo('body');

I changed "a.anchor" to "form.anchor", but it doesn't work correctly. When I first load mydomain/#login IE still jumps down to the top of the form. Then if I refresh the page it again displays the dialog box but doesn't jump down.Any idea how to globally just prevent IE from jumping to any form/anchor names?

Posted: Apr 21 09 at 18:36

View 3 Replies!   View Related
Toggle Text Keeps Jumping Back To Top Of Page?
I've tried many scripts and workarounds, but can't get this simple thing to work. As the title has it, how can I make my text NOT jump to the top of the page. here is the code.

<script type="text/javascript">
function toggleVisibility() {
document.getElementById("toggleMe").style.display = "";
if(document.getElementById("toggleMe").style.visibility == "hidden" ) {


Posted: Feb 15 11 at 13:19

View 2 Replies!   View Related
JQuery :: Stop Browser Window Jumping To Top Of Page?
I'm completely new to jquery and javascript and am just trying to get a simple script up and running. I've put this in the head of the document:


with a div with an id of "togglecontent" and a link with an id of "fadein" in the body about halfway down the page. The toggle works well, but when you click on the link, as well as "togglecontent" becoming visible, the browser window jumps to the top of the page, which obscures some of the toggled div. Is there any way I can stop this from happening?

Posted: 04-Jul-2009

View 3 Replies!   View Related
Html - Stop # Links That Call Functions From Jumping To Top Of Page?
How do you I stop my links like this:

<a href="#" onClick="submitComment()">

From jumping to the top of the page after the click?

Posted: Jul 19 09 at 16:17

View 3 Replies!   View Related
Php - Stop Script From Going Back To The Top Of The Page?
I'm testing some Jquery Ajax scripts and one of them is actually quite nice. The only problem I have with it, is that when it refreshes my div, it takes you back to the top of the div. The div loads MYSQL results from an outside php script. So if the user is halfway down the page reading, when the ajax call goes out, it takes them to the top of the div.


So would it be possible to have just a stack effect by modifying the code, or would I need to look at a completely different option? Also I would like to note that after so long, this script starts to fail. It gets to the point where it's constantly refreshing the div. No 20 second wait, just again and again.

Posted: Sep 7 11 at 0:20

View 3 Replies!   View Related
Keeps Jumping Back To Focus?
I have a validation function and the this is the last thing it does.

[code = var mytext=document.getElementById("sizip")
if(check5(mytext,"Zip Code must be 5 digits.")==false)
{mytext.focus();return false;}
function check5(mytext,alerttxt){


It will validate ok, if I do not have 5 digits, I get an error box.

But then if I click the accept button again, it puts focus back on my zip code with no error.

Posted: Nov 23rd, 2009

View 1 Replies!   View Related
Stop Cursor From Jumping To Beginning/end Of Textbox On Up/down Key?
How can I prevent the cursor from jumping to the beginning or end of a textbox when up or down arrow key is pressed, using JavaScript and jQuery?

Posted: Sep 17 11 at 19:49

View 1 Replies!   View Related
Stop Browser Window From Jumping On A #ID Hash Link ?
Got a client who is strictly no javascript, but in this particular circumstance, I don't think I can avoid it.

I've got a "next / previous" featured area situation going on using CSS (overflow: hidden and position: absolute) - where the click next or previous (a href="#section...") then brings the relevant div ID into view -but, the browser jumps to the top of the screen which is really very annoying.

What's the simplest possible way to prevent this jumping from happening (with javascript) - yet still be usable for users with javascript turned off?

Posted: Sep 29 10 at 12:26

View 1 Replies!   View Related
Stop Cursor From Jumping To End Of Input Field In Replace
I'm using a regular expression to strip invalid characters out of an text input area in javascript (running in IE). I run the replace function on every keyup event. However, this makes the cursor jump to the end of the text box after each keypress, which makes inline editing impossible.

Here is it in action: [url]

Does anyone know how to make it so the cursor does not jump to the end of the input box?

Posted: Nov 21 11 at 22:49

View 1 Replies!   View Related
Simple Password Protect - Stop Going Back To The Page With The Form After Submit It
Let me start out by saying that this is for a small-time page with absolutely zero valuable information. PHP or server-side is way beyond the scope of my goals for the project.

Basically, I have a form on a page which I want to use to submit a password. However, I have realized that using the form submit always makes the browser return to the page with the form.

Well, that's not good when I want to redirect using javascript!

My javascript is:


My form HTML is:


How can I get this to stop going back to the page with the form after I submit it?

Posted: February 22nd, 2009, 04:45 AM

View 3 Replies!   View Related
Jquery :: Sliding Panel Jumping Back To Home When Clicked?
I made a vertical sliding panel on a 1page website (click psssst on the top right).All in all it works fine, it slides up and down properly (still a little bump on the button when sliding, but no biggy).The problem is when you scroll to the right and then click the sliding panel it jumps back to the beginning of the page.

Posted: Jul 8 11 at 7:47

View 2 Replies!   View Related
Stop A Link From Changing The Position On The Page (maintain Scroll Back Position)
I have an href tag with an image nested inside it and I want to be able stop the page jumping back to the top after it is clicked.


the href does not post back it fires a jQuery event on the page.

<a href="#" onclick="javascript:SendPlaylist()" style="border:none;" class="addButton" ><img style="border:none;" src="/Images/icons/icon_add.gif"/></a>

Posted: Nov 2 10 at 15:22

View 6 Replies!   View Related
Back Button - Stop The Initial Load Of Back Button From Working?
I'm using a javascript back button link and forward button link to control the user's history inside a modal/lightbox window.

The challenge I have is when the modal window is launched, and the "back" and "forward" buttons are present for the user to click, if the initial javascript back button is clicked when the window opens, it actually closes the modal window, because the javascript history is taking the user back to the page PRIOR to the opening of modal window.

So, in essence, I'm trying to disable the "back" button from working on the initial load of the modal/light box.

Is this possible? Here's a demo of what is happening. [URL]

<a href="javascript:history.go(-1)">Back Button</a>
<a href="javascript:history.go(1)">Foward Button</a>

Posted: May 29 10 at 16:22

View 1 Replies!   View Related
JQuery :: How To Prevent Page Jumping
have simple slideshow here:n i v o n l i f e/category/2 (please remove white spaces)on the right you will see "More in Travel:" and then arrowsscroll page a bit down and click arrow you will see that page scrolling jumps up. how to keep window positio

Posted: 08-Nov-2010

View 8 Replies!   View Related
Image Link Jumping To Top Of Page ?
I am using a javascript gallery plugin, Galleriffic, to display an image gallery. I am having an issue with it as when the image is clicked it keeps jumping back to the top of the page. The problem with this is that the thumbnails which are underneath the main image on the page aren't visible and the user must then scroll to see them.

Is there any way that I can change this so that the link on the image doesn't make the page jump back to the top? I don't have my version online but the website will show you the code that is being used.

Posted: Jul 22, 2009

View 8 Replies!   View Related
Prevent Page From Jumping To The Top Onclick JS?
I have this inline JS call to a function inside an anchor tag and when click it fires the JS function however I don't want the page to jump to the top when I click it.

<a href="#" title="link" onclick="javascript:runMe()">Click Here</a>

And I have this inside the function:

function runMe() {
// do something
return false;

I thought the return false would be the correct way to prevent it to jump to the top but it doesn't work?

Posted: Aug 27 at 2:17

View 1 Replies!   View Related
Iphone - Webkit Causes Page Jumping
Using this code


Whenever t() is called, the page jumps to the top of the screen. The {} are server parsed variables, but they should be causing any problem. By jumping, I mean that the page, scrolled to the bottom, suddenly jumps to the top of the page

Posted: Mar 9 11 at 17:49

View 1 Replies!   View Related
Get Code To Execute Inline Instead Of Jumping To Top Of Page?
so im working on a piece of jquery/JS which executes (drops down a new div) when you click a link. I have the links setup as

<a href="#" id="d0">Execute 1</a>
<a href="#" id="d1">Execute 2</a>
<a href="#" id="d2">Execute 3</a>

And the jscript detects when d0, d1 or d2 is clicked and executes my script. It all works perfectly, however when you click on a link it will jump to the top of the page as a side effect of the a href="#" I assume?

Posted: 03-13-2011, 03:58 PM

View 1 Replies!   View Related
JQuery :: How To Prevent Click On Link From Jumping To Top Of Page
I'm currently using <A> tags with jquery to initiate things like click events, etc.
Example is <a href="#" class="someclass">Text</a>
But I hate how the '#' makes the page jump to the top of the page...what can I do instead?

Posted: Jul 15 10 at 5:36

View 9 Replies!   View Related - Stop A Post Back By Using Confirm?
I have an aspx page with a button on the page:

<asp:LinkButton ID="btn_Delete" runat="server" OnClick="btn_Delete_Click" OnClientClick="ConfirmDelete();" Text="Delete" />

Confirm delete looks like this:

function ConfirmDelete() {
var answer = confirm("Are you SURE you want to delete this item?");
if (!answer) {
return false;

I had assumed that this would prevent the page from posting back if the user clicked cancel, but it still appears to be posting back. Is there some way I can prevent postback using confirm?

Posted: Jun 23 11 at 17:12

View 1 Replies!   View Related
Copyright 2005-08, All rights reserved