My stuff has to run cross browser, and in multiple environments.
I use a global variable to store the base URL for the current run. The name mapped items, and anywhere it's used in the script, use this value. It can also contain wildcards.
For example, a page in my name map will use two properties to identify itself.
The first is the URL which uses the global variable and tends just to be the base part of the URL used through out the site (eg -
http://website.com/* ) with a * wildcard on the end. The second property is the ObjectIdentifier. Which is just the URL again. Except in this case the base part of the URL is wildcarded. (eg: *section1/page1 ). So the two value combined uniquely identify the page as -
http://website.com/section1/page1I also store a page for global objects common throughout the site that only uses the base URL. That way any controls common on multiple pages can be stored against a single page object with all the global controls attached to it. Saves having to map what is effectively the same control time after time and means distinct pages only contain their distinct objects.
As I also use a keyword and data driven framework, the value is set by the user and can be changed during the run if required.
Works well.