AP.navigator.getLocation() provides a JSON object, but not the product’s base url,
AP.context.getContext() also provides a JSON object, but not the product’s base url,
Rationale: When some clicks an
- We use AP.navigator.go() so they benefit from internal navigation,
- Except if they use shift+click, middle-click or ctrl+click, in which cases they want to open in a new window. For those cases, we need to avoid JS navigation, and provide a suitable
href value, starting with the product’s base url.
PS: We can’t get the URL from xdm_e because it is deprecated, and AP.getLocation() is not documented anywhere.
If you use ACE, you can put the host URL in your .hbs template in a variable in a tag. (Or similar solution with another stack.)
What @marc says works when you’re rendering stuff in your backend. But if you only have static resources, there’s two ways to do this I’m aware of:
- Using the
data-options="base:true" parameter in the
all.js script tag and then picking up the resulting tag from the
<base href="https://<instance>.atlassian.net/..." target="_parent">
The second method is documented here. Hope this helps!
The second option (documented) is quite nice, BUT the tag disturbs all relative links on the current page.
I’ll just add:
- AP.getLocation(callback) (undocumented): It returns the entire current URL of the parent frame. It is different from AP.navigator.getLocation().