Forum Moderators: open

Message Too Old, No Replies

Breadcrumbs Help

useing file name instead of title

         

Candlelight

8:23 pm on Sep 15, 2005 (gmt 0)



I have been trying to make or find a java script that shows the name of the html file instead of the title of the page. Everyone I have found uses the title for this is the easiest way to make a breadcrumb nav bar.

Let me see if I can try and explain what I'm trying to do.
You make a page and save it as "mypage.html" but in the source code of that same page you make the title of the page "all about my page"

I'm trying to make a java script that shows the "mypage" without the .html and not what is in the source code for title.

Can anyone please help me with this?

When it comes to java script I'm very much not in the know so any and all help is greatly appreciated

garann

8:32 pm on Sep 15, 2005 (gmt 0)

10+ Year Member



Here's a bit of script that should get it for you:

var parts = location.href.split('/');
var nameOfPage = parts[parts.length-1].split('.')[0];

There might be something more direct, but I don't know what it would be...

Bernard Marx

8:36 pm on Sep 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The easiest way is to use a regular expression on the
window.location.href
property, that removes

- everything before the last slash
- everything after the last dot

alert( 'This page is'+ window.location.href.replace( /^.*\/[b][red]¦[/red][/b]\.[^\.]*$/g, '' );

! But be aware that WebmasterWorld corrupts the pipe symbol ( ¦ ) into what you see. Replace the broken pipe with an unbroken one - or the code won't work!