JQuery :: Stop A Page Scrolling When Div Is Toggled?

Jan 11, 2011

I have two divs that are in the same parent div, only one is shown at once. When I toggle the one that is smaller (height-wise), the position of the scroll bar (and hence the user's current location on the page) remains the same. But when I toggle back to the taller div, the scroll bar launches you back up almost to the top of the page.Is there a way I can stop this from happening? I tried return false which i knew wouldn't work. I also looked into scrollTop() but that doesn't seem like it will be of any help since it only returns values and does not set any values?

View 2 Replies


ADVERTISEMENT

JQuery :: Scrolling Toggled Elements To Top Of Viewport

Jun 5, 2010

I'm using a simple toggle function to reveal divs when clicking on the associated heading. What I'm aiming to achieve:
1. When the heading is clicked, the hidden div will be revealed and the page scrolled so that the heading is at the top of the viewport.
2. If the page has insufficient height for the heading to move to the top, the page height will be increased to allow this to occur.
3. When the heading is clicked again, the div will be hidden but the heading remain in its current position at the top of the viewport. If a div is being toggled closed when not at the top, the page having been scrolled, then it should remain in its current position.

Other things to consider:
Preventing the amount of any generated empty space at the page bottom from being sufficient to fill the entire viewport.

Current state of play:
The code below will move the heading and revealed div to the top of the viewport if the page height is sufficient. When the div is hidden again, the heading drops down to its original location on the page, which is disorienting for the user.

Markup
<h2 class="trigger">Switch<h2>
<div>Content to toggle</div>

jQuery
$(document).ready(function() {
$('.trigger').next('div').hide();
$('.trigger').click(function() {
$('html,body').animate({scrollTop: $(this).offset().top}, 500);
$(this).next('div').toggle();
});
});

View 1 Replies View Related

Stop Page From Scrolling On An Onclick?

Jan 21, 2009

<input class='absmiddle' type='checkbox' name='chg' id='chg' onclick='toggle(this); return false;'>

I thought the return false would prevent this but the page scrolls up a bit. What's wrong?

View 2 Replies View Related

Auto Refresh - Stop Page Scrolling

Apr 15, 2010

I'm attaching my php test file but this is a JS problem. When I scroll down in the web page and the meta refresh hits, in Windows Safari and IE6/7/8 browsers, the web page re-positions back to the top. In Opera and FF the page refreshes but it stays where it is. Can someone look at my test script and see why it is not working in IE and Win Safari? My goal is to have the web page not re-position to the top on the auto refresh.

View 4 Replies View Related

JQuery :: Make Scrolling Banner Stop On Last Slide?

Nov 8, 2010

I have a rotating banner that cycles through all the images I load in. But I want the banner to stop on the last slide instead of going back to the first slide again.

At the moment the code I'm using to scroll through is:

$(document).ready(function() {
$('#slider').cycle();
});

View 1 Replies View Related

JQuery :: Scrolling Browser Window - Two Demos Of Scrolling Page Content

Feb 17, 2011

jQuery - Scrolling browser Window. I have two demos of scrolling page content with jQuery.

This one - [url] is scrolling the contents inside a container and it works as I wanted on Mac/PC

Code:

I need the same effect as above but I need to scroll the whole browser window.

I have a demo here - [url]

Code:

Problem here is on the Mac the transition are jumpy and it seems to flash the first yellow div before sliding up or down. Testing on a PC it will slide down but won't slide up. How can I get the whole browser window to slide up and down with a smooth transition.

View 1 Replies View Related

How To Stop Javascript Dropdown Menu From Scrolling?

May 19, 2003

I'm trying to place a javascript pulldown menu in a layer at the top of my page.

Everything seemed to work great until I noticed the menu always stays visible as you scroll down the page.

How can I make this menu stay put exactly in the layer (yellow bar) and not scrolldown? Code:

View 5 Replies View Related

Stop Automatic Scrolling In JMyCarousel On Mouseover?

Dec 18, 2009

I have been searching and trying out different javascript carousels and found JmyCarousel to be the one that best suits my needs. I made a few changes (I changed the speed, image size, and the scrolling has been set to automatic) and it works almost the way I want it to except for one problem: I can not figure out how to stop the carousel from scrolling on mouseover.I have changed the value evtStop to 'mouseover' but this has not solved the problem. I have no idea what else to change, as I have no knowledge in JavaScript.Here is the html code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

[code]....

View 2 Replies View Related

JQuery :: Using Toggle To Call A Function Continuously Until Toggled Again?

Aug 4, 2010

I have been trying to get a function to runcontinuouslywith with toggle function. Here is the snippet of code:

$('#infinite').toggle(function() {
$(this).css({"color":"red"});
infiniteloop();
},

[Code]....

The above code should run after the first time the button is clicked, once it is clicked again the function should no longer run.

View 2 Replies View Related

Error After DIV Toggled To Visible In Firefox

Mar 29, 2009

I'm pretty new to web programming. I am working on an idea for a site involving bands and their fans... and have only done a little prototyping on it so far. It's coming along okay, but I have run into an odd behavior coming from firefox where once an initially invisible DIV is toggled to visible... and then the space bar is pressed, the whole display bumps upward on the screen and mostly out of view. I've tried several things to isolate the issue but haven't found the cause, yet. The screen doesn't act oddly upon space bar entry within IE... just in firefox.

View 2 Replies View Related

Change Header Image Via Toggled Buttons?

Jul 26, 2010

What I've made so far is a page header image with 4 buttons to the side of that, which when clicked will change to a diff image (sprite image, triggered by some javascript I found on the net to change the class of the buttons so that the image changes - and it looks toggled). This works fine and if a 'toggled' button is clicked again then it will delete the class the javascript adds and 'untoggle' it. The final aim of this is when this page is first loaded then none of these buttons are toggled and a default image in the header is shown.

But when one is selected then I want the header image to change to one that is associated with the button that is pressed - I was able to achieve this with an onmouseclick action on the button to change the header image, but if the user then clicked the button again (untoggled it), how would I then be able to change the header image back to the default one? Could this be achieved by some javascript that changed the class of the header image to the one associated with the button pressed, and then if its pressed again then it clears the header image class?

Below is the code
HTML Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
[Code].....

View 9 Replies View Related

JQuery :: Scrolling DIV Overlap Footer On Page

Sep 23, 2011

I'm using this small js to scroll a div, the problem is that it goes all the way to the bottom of the page and overlapping my footer, I need it to stop before the footer. [URL]
$(function () {
var msie6 = $.browser == 'msie' && $.browser.version > 7;
if (!msie6) {
var top = $('#contact').offset().top - parseFloat($('#contact').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#contact').addClass('fixed');
} else {
// otherwise remove it
$('#contact').removeClass('fixed');
}});
}});

View 2 Replies View Related

JQuery :: Stop Page From Jumping To The Top?

Mar 29, 2011

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 () {
$('ul#aboutsub').slideToggle('medium');
});
});

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

View 3 Replies View Related

JQuery :: Scrolling Page Based On Focus Of Elements?

Mar 18, 2011

I am creating a plugin that gives keyboard navigation to tabular table acrossmultipletables.When I have rowsthat run off screen I would like to scroll the window down.. and the reverse is true, when navigating up.Logically I need to get the position of the element that has focus and specify how much to scroll the window.

View 2 Replies View Related

JQuery :: Toolbar Changing Position While Scrolling The Page?

Oct 11, 2011

I'd like to build a toolbar which is positioned as "fixed" ad the bottom of the page (till now even too easy), but at a defined point I want it to change position from fixed to relative, sitting upon the footer of the page and remaining there.
Take a look at this exemple, which is perfect.. [URL] To do that I tried to search something on the web, but I've found only this: [URL] Now, the voice sticky elements seems to be what I was looking for but actually it is "upside down" and I couldn't be able to edit it to reverse it.. I'm trying (without any good result) to edit this part of index.php:

<script type="text/javascript">
$(document).ready(function() {
$('.top').addClass('hidden');
$.waypoints.settings.scrollThrottle = 30;

[Code]....

Am I right using this script? how can I find something "ready-to-use" on the web? or if there's nothing, how can I edit this one to fix my needs? And first of all... what is the name of this particular function (I mean something which change position while you scroll the page?)

View 9 Replies View Related

JQuery :: Stop Page From Jumping To The Top OnClick?

Oct 26, 2009

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");
$("#olderstories").click(function(){
showLoading();

[code]....

View 2 Replies View Related

JQuery :: Stop Browser Window Jumping To Top Of Page?

Jul 4, 2009

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:

[Code]...

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?

View 3 Replies View Related

JQuery :: Prevent .load Scrolling Back To Top Of Page When Loading New Content Into Div?

Jun 24, 2011

I've gotten .load to load content into a div but if the window is not at the top of the page it scrolls back to the top each time the new content is loaded but I wanted to avoid any sort of change on the page other than the content in the div. It seems pointless if the user has to scroll back down to the div where the content is each time? code...

Is there a way to keep the window in the same position? Also while I'm at it - is there a more efficient way to write this considering I have 9 pages or should I just write this code out for each instance?

View 2 Replies View Related

JQuery :: Scrollto Duration - Add Scrolling Buttons That Scroll The Page Onmousover

Oct 12, 2009

I'm trying to add scrolling buttons that scroll the page onmousover. They work great, however, since the duration is a fixed value, and the distance changes based on how far the user scrolls, it sometimes scrolls fine (when the distance and duration are proportioned), and very slow (when the duration is way higher than the distance)...

Is there any way to change the duration based on the distance?

To make some sort of "speed" setting, instead of a constant duration?

Here is the code

It just scrolls a div that has overflown content.

View 2 Replies View Related

JQuery :: Stop Firing Change Event When Page Loaded?

Feb 23, 2010

Here's my code. when you load the page, alert shows up. is there a way to stop that? i only want alert to show when I change the selected item from dropdown list.[code]...

View 2 Replies View Related

JQuery :: Stop Page Auto-refresh If Checkbox Is Checked?

Jun 20, 2011

Im fairly new to JQuery and need some help. Googling failed me :o have a web page that initially auto refreshes every 30 secs and has a bunch of checkboxes that are initially unchecked. I am trying to make it so that if at least one of those boxes it checked the page stops auto refreshing (without reloading the page, preferably). Is this at all possible? I am using Perl to generate the html.

My auto refresh is in the header, but im open to sticking it somewhere else, as long as it doesnt create crazy memory consumption that i've read about on these forums:<head

[Code]...

View 5 Replies View Related

JQuery :: Stop Tabs With Query Strings From Reloading Page?

Aug 18, 2009

I have a set of tabs that are set with an href that adds a query string to the url such as "?t=1", meaning the first tab is selected.

Technically it works just fine but every time I click a tab it reloads the page and I'm not entirely sure how to stop this.

I'm using a jquery plugin to handle the query strings. [URL]

Here's the piece of the code that matters:

var url = location.search;
var tab = $.query.get('t');
init(tab);

[Code].....

View 4 Replies View Related

JQuery :: Scrolling Text - Cut And Scrolling From Start To End

Aug 6, 2010

im searching for a plugin/code example for text scrolling. I got some text in a <div> if text is longer than for example 300px it gets cut and is scrolling from start to end, stops for a second and then scrolls back, stops and all over, and if its not long enough than 300px then just displays normaly. Something similar to the Song name scrolling inin anyMP3 player.

View 2 Replies View Related

Scrolling With Page

Mar 3, 2002

What I need is a javascript, that scrolls an image togheter with the page, so, the images is always visible. You can see an example on britannica.com , in the right bottom corner there's a little '+', that's scroll with the pages, well I want the same with a simple image.

View 6 Replies View Related

Js - Add Hash To URL Without Scrolling Page

Sep 17, 2009

the problem with ajax is that the page content generated cannot be bookmarked, nor does the back button work (in some browsers), ive read about history libraries and all sorts of heavy stuff, but i would like to know one simple thing.i want to add a Code JavaScript:

window.location.hash='#';

upon a link click, but theres a catch, when this hash add's, i don't want the screen to jump to the top, i want it to remain where it is.clarification:

1. i open page
2. i scroll down
3. i click link that adds a hash (maybe with a value #test)
4. the page MUST not scroll back to the top.

note: i see that adding a hash has different effects in different browsers, is there a cross browser way?

View 2 Replies View Related

Load Page While Scrolling?

Jan 28, 2011

how to load page while scrolling? For e.g. If i want to load 200 records, i will first load 100 records and when the scroll reaches bottom, i will have ajax to get the remaining records. Here, when i get the next set of rows (in responsetext), these rows are seen as text and not as table rows.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved