You need to sign in to do that
Don't have an account?
Francesco Sciuto
How to retrieve Site.BaseURL from JavaScript
I have an object layout displayed as a tab inside Sales Console. I have some Javascript attached to the onClick event of a button on the layout. In the Javascript I would like to retrieve the Base URL displayed in the browser. So if I have 'https://[instancenumber].salesforce.com/console' I would like to get 'https://[instancenumber].salesforce.com'. I use within Javascript:
console.log({!$Site.BaseUrl});
but I always get NaN. I know that I might use Javascript directly but I would like to know why this Salesforce approach does not work and I can make it work. Thanks
console.log({!$Site.BaseUrl});
but I always get NaN. I know that I might use Javascript directly but I would like to know why this Salesforce approach does not work and I can make it work. Thanks
Renato Solu
The correct use is:
because the tag gets replaced by the actual content, and strings in JS need to be wrapped with simple quotes. Srini Grandhi
It did not work for me.