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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing anchors from url 1

Status
Not open for further replies.

onressy

Programmer
Joined
Mar 7, 2006
Messages
421
Location
CA
Hi in JavaScript i'm trying to remove the anchors from the url when the page is refreshed/loaded.. any ideas?

thanks
 
like this?

Code:
onload = function () {
    if ( window.location.indexOf("#") > -1 ) window.location = window.location.split("#")[0];
}



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
thanks cLFlaVA, bhut it doesn't seem to work, any other suggestions? thanks

Code:
function doIt() {
    if ( window.location.indexOf("#") > -1 ) window.location = window.location.split("#")[0];
}
window.onload = doIt;
 
sorry, this should do it:

Code:
function doIt() {
    if ( window.location.href.indexOf("#") > -1 ) window.location = window.location.href.split("#")[0];
}
window.onload = doIt;



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
sweet bajoulyas, thanks!
 
and have a great day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top