/* ** This functions retrieves the file name of the supplied path, ** excluding the extension. Both / (slash) and \ (backslash) are ** handled as directory separators. If no file name is included ** in the path, the file name "index" will be returned. ** ** Example: ** ======== ** path = "/C:\Hemsida\TPP-linktest\links.html" or ** path = /links.html ** ** ==> "links" */ function get_pagename(path) { last_slash = path.lastIndexOf("/") last_backslash = path.lastIndexOf("\\") if ( last_slash > last_backslash ) index = last_slash + 1; else index = last_backslash + 1; if ( index < path.length ) filename = path.substring(index, path.length); else filename = "index.html"; splitted_name = filename.split("."); name = splitted_name[0]; return name; } /* ** This functions retrieves the file name of the current page, ** excluding the extension. See get_pagename() for details. */ function pagename() { return get_pagename(location.pathname); }