Reg Exp
Web Design
Notes Client
Using A Base Href
You're probably familiar with the famous formula:
@ReplaceSubstring(@Subset(@DbName; -1); "\\" : " "; "/" : "+")
which will take the path to the current database and make it "browser-friendly".

After getting sick of adding this to every single link and image tag that needed it, we decided there had to be a better way.

Well, there is a better way

In standard HTML, in the section you can include what is called a "base" href. The tag looks something like this:

<BASE href="http://myserver.com/mysubdir/mydatabase.nsf/">

This specifies the starting poing for all relative URL's in the page, no matter if that relative URL is for a link or an image tag or anything.

How do I use this?

Well, first you place a hidden, computed for display, text field on your form called HTTP_Host. The value for this field should be HTTP_Host (no quotes - it should compute to itself).

Then, in the HTML Head section of your form, put in the following formula:

"http://" + HTTP_Host + "/" + @ReplaceSubstring(@Subset(@DbName; -1); "\\" : " "; "/" : "+") + "/"

Now you can use relative URL's on your page and you know exactly where they are coming from. For example, an image tag like <IMG SRC="myimage.gif"> will go to the current database and look for the image resource named myimage.gif.