Friday, March 25, 2011

Relative or absolute path in URL

When a javascript method or html link refers to an element in the url, if the relative path is used, the path base is the current displaying html page. As a result, the target location will be different depending on the current displaying page's location. If the javascript method or html page refers to an element using absolute path format, then it is always based on the root folder of the virtual directory, and the target location is irrelevant to the current displaying page's location.

The format of absolute path starts with a single forward slash, avoiding using a back slash since some clients may not support it.

The format of relative path starts without any slash. If the relative path starts with '../', it will go to the parent folder of the current displaying page. However, if it already reaches the root folder of the virtual directory, then the root folder will be used to locate the target item.

Jonathan

No comments:

Post a Comment