Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you use script to jump to <a> tags without navigating?

Status
Not open for further replies.

CubeE101

Programmer
Nov 19, 2002
1,492
US
In standard HTML, you can setup a set of anchors (<a>) to jump from one area to another...
Such as:
Code:
<a href="#below">See Below</a>
.
.
.
<a name="below"></a>
<p>Below...</p>

is there a way to do this via script (vb or java) so that the URL does not change...
Like, from:
www.mypage.com
to:
www.mypace.com#below

I would like to use the onclick command, in either an <img> tag or <a> tag with href="" and "...;return false;" so that the URL does not change, but the location/focus still jumps to another area...

Is this possible?

Thanks in Advance,
-Josh

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
I honestly cannot think of a way why you would want to do that, but you could put your whole page in a frameset. Anything you click won't be registered in the URL address bar then.
 
You may be able to do something with javascript that took a url parameter and scrolled the page to a position.

As Vragabond said, the simplest way would be to use a frameset.

Then again, is it really worth it? Why would you want to hide the URL from the user?

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
I don't want to hide the URL...

I just don't want the #xxxxx to show in the URL

The <a> positions are generated at runtime with XML, and when you reload the page, they won't be there...

It's not that big of a deal, I just think it looks sloppy to have #xxxxx cluttering up your URL, when it serves no real function...

For example: you can't copy the link, then come back and paste it to get to the same location...

So why have it in the URL...???

I do not want to use Frames, it's not that big of a deal...
I just want to know if there is a way to scroll to a tag without modifying the URL, not hiding the URL from the user...

Click the Visit My Site below to see what I'm talking about...

*Note: It's currently only set up for IE Browsers...
I'm a VB programmer so I like to lay everything out in vbscript then flip it to javascript when the bugs are out...
(I'll probably do that tonight or later today...)

------------------ Just Found What I was looking for...

scrollIntoView(true)

Such As:
Code:
<html>
  <body>
    [b]<a href="" onclick="test.scrollIntoView(true); return false;">Jump Down</a>[/b]<br />
    blah 1<br/><br/><br/><br/><br/><br/><br/>
    blah 2<br/><br/><br/><br/><br/><br/><br/>
    blah 3<br/><br/><br/><br/><br/><br/><br/>
    blah 4<br/><br/><br/><br/><br/><br/><br/>
    blah 5<br/><br/><br/><br/><br/><br/><br/>
    blah 6<br/><br/><br/><br/><br/><br/><br/>
    blah 7<br/><br/><br/><br/><br/><br/><br/>
    blah 8<br/><br/><br/><br/><br/><br/><br/>
    blah 9<br/><br/><br/><br/><br/><br/><br/>
    blah 10<br/><br/><br/><br/><br/><br/><br/>
    [b]<a name="test"></a>[/b]
    Some Text Below
  </body>
</html>

Thanks Anyway...
-Josh

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Dunno if that will be cross-browser compatible, but you'll find out I suppose.

I'd just leave the #label in the URLs anyway. If someone bookmarks it and tries to display it, the browser will just load the page scrolled to the top if the #label doesn't exist - i.e. just the same thing as if there wasn't a #label in the URL.

Be aware, by the way, that if you're using client-side scripting - be it VBScript, Javascript or whatever - to output the content of your site, it's going to look blank to search engines (and anybody else with scripting switched off). Seems a shame to do all that work if nobody's going to find it.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top