logo

New Response

« Return to the main article

You are replying to:

  1. This is a flexible version of this code I just wrote. It's supposed to return different parts of the URL based on your needs.. might be overkill for most people *shrug*

    function getPath ( part ) { // Purpose: return the requested URL Path from the document URL // Called: Helper function var path = ""; var arrProtoSplit = document.URL.split('://'); var arrSlashSplit = arrProtoSplit [ 1 ].split ( '/' ); for ( var x = 1; x < arrSlashSplit.length; x++ ) { if ( arrSlashSplit [ x ].indexOf ( '.nsf' ) != '-1' ) { db = arrSlashSplit [ x ] ; break; } else { path = path + arrSlashSplit [ x ] + "/"; } } if ( part == "proto" ) return arrProtoSplit [ 0 ] else if ( part == "serverName" ) return arrSlashSplit [ 0 ] else if ( part == "path" ) return path else if ( part == "dbName" ) return db else if ( part == "thisServer" ) return arrProtoSplit [ 0 ] + "://" + arrSlashSplit [ 0 ] else if ( part == "thisDB" ) return arrProtoSplit [ 0 ] + "://" + arrSlashSplit [ 0 ] + "/" + path + db else return document.URL }

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: