document.write specified text based on which file is loaded

wxdqz

New Member
I've got a floating menu working for a web site that I'm building. With the floating menu, they also want the short version of the page title displayed. I'm sure this can be done using Javascript so I don't have to create a separate menu.js file for each page (defeating the purpose of the darn thing in the first place).

I found this code to get the filename:
var filename = window.location.href;
filename = filename.substr(filename.lastIndexOf("/") + 1);

It works just as expected. Now I tried to write IF statements, then IF and ELSE statements, then even WHILE statements, but I just cannot get it to "document.write(text) if filename == xyz.html. I've got 8 pages on this site so far, so I need to have the script write the specified text when the current file displayed.

Example:
if (filename = "xyz.html") {document.write('.: XYZ Main :.');}
if (filename = "abc.html") {document.write('.: About Us :.');}
if (filename = "def.html") {document.write('.: Contact :.');}
..... and so on .....

If anyone can help with how I can get this to work, I'd be very grateful!

Thanks
 
Back
Top