Catch Page Anchor Without Onload?
Dec 27, 2010how would I go about capturing the page anchor in the address bar without the onload function and without page refresh?
View 1 Replieshow would I go about capturing the page anchor in the address bar without the onload function and without page refresh?
View 1 RepliesWhat I want is for jQuery to do something when the page has loaded depending on the anchor in the URL.
For example:
domain.com/index.html#dothis
domain.com/index.html#dothat
domain.com/index.html#dosomethingelse
Do these come under the onLoad event or something else?
I currently have a script to jump to an anchor tag when the page loads:
<script type="text/javascript">
function goToAnchor() {
location.href = "myPage.html#myAnchor";
}
</script>
Now, I would like to take it a step further and would like to link from page A to page B that usually takes a while to load and once the page loads, run a script to jump to the specified anchor tag on the page after everything has loaded. I know I have to add some parameters at the end of the url link on page A, but that's where I get stuck.
But I was wondering is it possible to make it so that if you visited an anchor link: For example, let's say you visit:
Code:
[URL]
Then a code would run to let's just say... change the color scheme of the website. (And theoretically they same would happen with #v2/#v3, ect)
But the code would NOT run if the requested URL is just
Code:
[URL]
The reason I was wondering is I want the user to be able to "bookmark" a certain script per-say, so that when they revisit the site they don't have to reclick things to get back to where they were before.
I need to get the page to reload with the anchor in the link when it is clicked in a dropdown menu. For example if I am on 'www.domain.com/about/#2' and I then click on 'www.domain.com/about/#3' the url changes but the page doesn't reload so I need the page to reload, but keep the new anchor (#3).I gave the links with anchors a class of 'reload' and tried this:
$('a.reload').click(function() {
window.location.reload();
});
I would like to create a link from one page to another. Easy - I know. But I would like that link to to take me to a certain part of the other page, specifically towards the bottom of the page.
Is that possible to do? And if so, what are the different ways I can specify where in the page to go? (i.e. what are the parameters that I can play with)
I placed an anchor at the end of my long page inside a top <iframe>.
my entry field is in another iframe at the bottom. when i enter something and hit return, it adds a new line to the html file as well as <a name=END></a> tag (there is only one END tag at the end of the file)
I then request top frame to reload and goto END tag.
sometimes it works, sometimes it won't (IE). Is this normal ? Is it Frame related?
I am having trouble getting this to work on Ie6+.Basically i have a form which is below the fold which has validation using php on it. If there is an error when submitted the page will jump down to the form
Code:
<form ....><a name="Error1">...
using the [code].....
I have a script that scans an HTML document for headers and special comment tags for the purpose of generating a left-floating/position-fixed DIV that contains the document's outline or "table of contents." Within the DIV are lists (UL element by default) whose items (LI elements) are jump-to links (A elements) to the points (headers, special points marked for inclusion in table of contents) in the document. The problem is this. I have typical HTML document with links that jump to points (usually headers) inside the document, as shown below:
Code:
<body>
<p>This is addressed <a href="#later-text">later</a> in this document
<h1><a id="later-text"></a>Header Text</h1>
<p>...
</body>
But my script, being a document outliner that finds headers in a document, inserts another anchor as a jump-to point just before the first occurrence of text in the header (inserted A element shown in red below). This somehow disables the document-coded jump anchor (shown in blue below). And it occurs in FF and IE, which suggests it is not a browser-specific issue. Why does it occur? Is there something in the HTML spec that states that two anchors to which a jump occurs are not allowed to be adjacent elements in the document?
Code:
<body>
<p>This is addressed <a href="#later-text">later</a> in this document
<h1><a id="later-text"></a><a id="jump-1"></a>Header Text</h1>
[code]....
To reproduce what I am seeing, search for the text "Why Is A Survey Done". The first occurrence is a within-document jump-to link, which should jump to a header below it. If the script execution to generate a document outline is disabled, the jump works. But if the script is executed and the document outline generated, the jump-to link does not work.
Is it possible when you click a link, it loads a new page at a given anchor tag?
View 2 Replies View RelatedAdapting this code may not be the best method, see what you think.
I have a page where certain actions cause the page to reload and then jumps to an anchor (e.g. #title gets appended to the url) which is disorientating, I think it will soften the blow if the page scrolls to the anchor.
This is code I use to scroll to anchors with links on a page code...
I see that this is a click function. Can this just be amended so that it checks the url and scrolls accordingly?
I have a little help page that I open as a popup. Is there a way I can place anchors on the help page and based on the link the user clicks the help page will display that section?
View 3 Replies View RelatedHaving a little bit of trouble with a site I'm currently working on I'm using some AJAX for the instant g-mail/facebook style navigation, you know the kind, with no refreshes, etc. Problem is, to allow for back/forward and bookmarks, I currently use a URL that looks like:[URL].. This is fine, not a problem... The issue comes into play when I want to open up the news.html page, from my home.html page, and have it open to news item #6 (for example).
I can't add a #, because one is already being used to reference the anchor for the content div. Has anyone run into a similar problem before? If so, how did you resolve it? Can some jQuery be used to find the location of the news item div in question, on load, and scroll to it like that?
I'm new to jQuery and javascript but already very impressed with jQuery.I have a page divided in two columns (divs). When one clicks on the links in one column, it loads the php page in the other column. I have this working, but what i would like to do is that not only would it load the php page in the other column but also automatically scroll to an anchor in that php page
View 2 Replies View RelatedHave a drupal site and jquery update1.3. seems to avoid the posiblity to jump to anchor tags. In order to this I use this script for jumping on a page. I works..But how to I manage a jump, if the href is on a different page (not external!).Something like jump on pageload to an anchor.click on page node/5/products on link href: node/5/products/xyz/#anchor1 How do I manage this?
$(document).ready(function(){
$a[href*=#]").click(function(e){
$
[code]....
I have got tabs working great and have set up a rotate every 5 seconds but whenever it loads a new tab (either by clicking a link or rotating to it) it moves up to the top of the page as if it was following an anchor.
View 2 Replies View Relatedi have a page containing an iframe somewhere in the middle of it. the iframe stretche to the end of the page and its height is calculated from its content with javascript.
i want some of the pages i load into the iframe to have a "back to top" link at the bottom. but i can not put the anchor inside my iframe because my iframe doesn't start at the top of the page.
so i put the name linke of the anchor at the top of the parent page which has the iframe inside. but i couldn't find a way to call that anchor from within the iframe.
i'm sure this could be done with a simple code of javascript. how do i get to the parent frame within the iframe?
I have two pieces of Javascript attached to my open/close text boxes.
One for the visibility function:
<script type="text/javascript">
function toggle_visibility(id) {
[Code].....
The problem only shows further down the page, when I click to open a box it automatically goes back to the top of the page instead of staying at the user's current page position
I would like it to stop changing the page position onclick.
I have created a very very simple javascript that displays random text quotes. It is in Greek but here it is anyway: [URL]. It is in blogger and shows up as a gadget. My problem is that I need to make it reload by a button and at the same time go to the top of this gadget (using an anchor). The reason I want to do this is that I have been sharing this with other bloggers, but if they don't put it on top of their page, as soon as they press the button that reloads the page, they are in the top of the page and they would have to scroll down to find the quote.
I have tried to use window.location.reload with window.location.hash.
It works in Firefox, but not in IE.
I have been trying something like that:
<input type="button" value="Click to refresh" style="width: 130px" onclick="window.location.hash='#something';window.location.reload()" />
As I said, this works with Firefox, but not with IE9
Also, I can't define urls beforehand because I want other people to be able to use it to their own blog or website.
I'm working on a project where we're using JavaScript to let users swap styles on a page. To accomplish this, I'm calling the script via href="javascript:swapcss()" on the switch styles button.
Some pages on the site have anchor links. On those pages, if someone swaps styles without hitting any of the anchor links, all is well. But if someone hits an anchor link and then hits the swap button (at this point the URL is pageid.html#anchor), the page just reloads to their anhor point without swapping styles.
Does anyone have a workaround handy? I've tried several alternatives I've found online (href="#" onClick="action"; href="javascript void(0)" ). Nothing works for this case yet. Code:
Here is what I am trying to do with no luck: I am sending an HTML marketing e-mail with a call to action to watch a video on my website. Since html e-mail code has to be pretty generic and simple I want to have the link inside the email be something like [URL].. Once the anchor is received on the web page the video automatically pops up and plays.
View 3 Replies View RelatedFirst, my url looks like this [url]...
I would like, depending on the value of the anchor called, to add a class to the box related.[code]...
all try to explain my problem: i have this website:[URL].. i'm using Jquery Cycle to do a slideshow. I would like to know how to put a link on each colored square.
I know i have to find in "jquery.cycle.all.js" but i'm a bit lost...
vBulletin uses a template system so I can't create a separate element for everything -- we have had several people ask for a "skip to the next post" feature and I'd like to implement that for them My first thought was to use anchor tags such as:
<a name="$post[postid]">
for each post and then to create a link for "Jump to Next Post" which would advance the user to the next instance of <a name="$post[postid]"> in which the postid obviously would've changed. With that I didn't know if there was a way that I could have javascript look for the next instance of this, or to pull the postid number and add 1 to it to find the next post on the page. I'm also not sure if it would need to be as complicated as reading where it was at and then adding one and directing person to that anchor point, which is why I thought maybe it could just look for the next instance of <a name="$post[postid]"> and refocus the screen on that.
It doesn't have to be an anchor, it can be a hidden input, whatever makes the JS be able to seek it as a point to move the page to. We do have some members that select a different number of posts per page than the default, so I'm guessing that the plus one might not be a great idea if they used a smaller number per page and then clicked the last one, whereas people with more per post wouldn't need to stop at the same point before it no longer let them. If there's a solution for that, that'd be great as well (such as once it hits the last element on the page, it no longer receives instruction, goes to the top of the page, or something).
When you click a link it jumps to an anchor point on the page and scrolls there smoothly. I was wondering how I get the same effect if I want the link to jump to another page? A normal anchor point on another page would set the href to, for instance, 'index.html#contact' but it won't work in this case as the javascript isn't reading the '#'.
<script type="text/javascript" src="jquery.js"></script>
<script>
function goToByScroll(id){
$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}
</script>
</head>
<body>
<ul>
<li><a href="javascript:void(0)" onClick="goToByScroll('contact')">Go to anchor 1</a></li>
</ul>
I've used the ScrollTo plugin for header images for each topic and I have created a menu to change the content in the div(s) that contain readable content with ajax, so it looks like different pages with headers using the one page.
everything works well, but on browser refresh the page jumps down after the menu and on to the header.
Would anyone know a script that would deactivate all anchor links in the page so that page onload the page loads as default index.html instead of index.html#some_anchor