Building a new URL

This code extracts the HTTP path and NSF filename to get a URL prefix to chain to other areas in your Web application.

This code extracts the HTTP path and NSF filename to get a URL prefix to chain to other areas in your Web application.

It will extract URLs that contain the ".NSF" or the database replica ID in the current location.

  
 function getPath() {
var curURL = "" + window.location;
var pos = curURL.indexOf(".nsf"); 
//find the position var path = "";

if ( pos != -1 ) {
 path =  curURL.substring(0, pos) + ".nsf"; } 
else {
 var URLInfo = curURL.split( "/" );
 path = URLInfo[0] + "//" + URLInfo[2] +
 "/" + URLInfo[3];
}

return path;
}

MEMBER FEEDBACK TO THIS TIP

This tip assumes that the URL is always lowercase -- it should be modified to accommodate (convert to either upper/lower case when searching for the .nsf).

—Scot H.

******************************************

The modified code below is in response to the comment from Scot H. about the assumption the prior URL was in lower case.

function getPath() {
var curURL = "" + window.location;
var pos = curURL.toLowerCase().
indexOf(".nsf"); //find the position var path 
= "";

if ( pos != -1 ) {
     path =  curURL.substring(0, pos) +
 ".nsf"; } else {
     var URLInfo = curURL.split( "/" );
     path = URLInfo[0] + "//" + URLInfo[2] + 
"/" + URLInfo[3]; }

return path;
}

—Dennis Potts, tip author

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Dennis M. Potts Jr. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was first published in November 2004

Dig deeper on JavaScript for Lotus Notes Domino

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close