How to make page autoscroll to DIV onload - javascript

I have a quicklaunch (bookmark list if you'd like) which will send the user to different pages with lots of text. So I want them to be sent to the specific paragraph.
Is it possible to make a page autoscroll to a specific DIV onload and how?
I'll live without the animation. If it can just go to it directly that'll make my day. Like when you have an <a href="#SomeId"> tag and when you click that anchor it sends you to that div.
Edit: If the user bookmarks the top paragraph, an ID isn't saved for the link. So in that case I just want it to go to the where the content div starts. How is this possible?

Try this:
window.location.hash = "myDiv";
This will change the hash to myDiv (and scroll to the element whose id attribute is equal to the hash).
Example.

Related

Remove scrolll after page load

I have wordpress site in which after complete one step of form
it redirect to second part but because of id added in URL it scroll
down where page id in hidden. But i want to prevent scrolling and
look like this
After complete first step it scroll down page also want to remove
this without change in url and hidden id.
Any Possibility by JavaScript?
I Have Solved It myself.It's HTML issue.

iframe: get active iframe

I have a page with multiple iframes, at a time one one iframe is active, and i would like to know which iframe is active currently.
I tried document.activeElement.id, but it gives correct result only when I click on page some where.
I tried this also but not giving me active iframe id.
Do you know any javascript/jquery api to know active iframe id.
Using jQuery you can try this:
var $focused = $(':focus');
The above will get the element that currently has focus.

Show/Hide Div's via <a> | Save Scrollbar | Save State

:)
I want to code a Forum where you can switch the divs (Sub Forums) which are shown via <a> tags.
I found this https://css-tricks.com/snippets/javascript/showhide-element/
And it works okay for the start, but sadly after I click on the link my scrollbar jumps to the top, I'd love to have it stay where it was before the click event. How can I achieve that? :)
Also when I refresh the whole process gets resettet (foo is always visible after refresh), can I somehow set variables so it remembers on which button we currently are and then, on a refresh, stays on that decision? :)
Just modify the href attribute of anchor tag
toggle

Make an Anchor Tag not fade out in a slide

I am trying to get an anchor tag(button) not to fade in and out of a slide.
http://demo.gbaus.com/index.html
The Get Quote button on the Home Page I want to stay visible at all times when changing through slides. Is this even possible?
I'm not sure what you trying to do
If it's about the location yes , It's possible, U should consider them as the positioned elements
give position absolute to them and place them On the Slider so they never move
but if you try to go to other pages and want to keep those elements on the page you shoud use something like HTML5 push state
provide more Information
I think you should use jQuery in this case. According to your source every time the slider changes it's image a new link ( tag) is created with new href attribute. That's why the link fades in and out with the image having an effect of jQuery.
But you can solve this.
1. Keep a single link as your button and change the href attribute with the change of images.
2. Take an array to keep all the link's or href.
3. On every image change only change the href attribute.

Get id of innerdiv in a iframe

I have a iframe that opens different page depending upon the items selected in a menu. Each page in a iframe contains div elements and tables.
My requirement is to set focus on the first div or table in a iframe. Therefore I am looking for a way to access id of first div or first table and set focus on it.
Since pages loaded in a iframe are depended upon the menu items selected, I couldnot use getElementById method to access elements inside iframe.
I have tried to access first div element in a iframe using following code :
var innerElement = iframeObject.contentWindow.document.getElementsbyTagName('div')[0];
innerElement.focus();
But , innerElement is regarded as undefined.
However I was able to set focus on iframe using :
iframeObject.contentWindow.focus();
but could not set focus on inner div.
Can anyone help, how could i access the first elements of a iframe?
If you're trying to reach out a specific HTML element from an external source (URL out of your domain), you can't do that forsake of DOM security reasons!!

Categories

Resources