0

With Summer 15 release Javascript in HTML home page Components is not allowed, but is allowed in VF components/pages included in home page side bar.

When I try to access DOM elements on salesforce page (outside the vf iframe which is hosted on visual.force.com domain) I get cross origin error.

If I enable CORS for visualforce domain (where VF pages are hosted), will I be able access salesforce DOM elements from VF sidebar components using Javascript?

  • 1
    Did you try it? It is reversible so give it a shot – Eric Nov 4 '15 at 17:00
  • Yeah, didn't work. – zuke Nov 4 '15 at 17:02
  • Browser/version? – Adrian Larson Nov 4 '15 at 17:05
  • Google Chrome 45. – zuke Nov 4 '15 at 17:25
2

Salesforce has been increasingly locking down the ability to modify standard pages via JavaScript and CSS hacks, because it interferes with their future plans for enhanced user interfaces (for example, see the Lightning Experience feature that was just released). By disallowing sidebar hacks, they've made sure that you can only write code that will be compatible with future technology. While you've not specified your use case, which may well be a valid use case, you'll still need to find another way that fits within the new model to do whatever it is you're trying to do. This may be using a Visualforce page override, a Visualforce or Lightning component, etc. There's a "correct" way to do whatever it is you're trying to do, but you'll need to find out what that way is.

  • I agree with you on the lighting experience. But for use cases like hiding a button, listview button, links, etc... replacing the entire page with a VF page seems to be an overkill. I think salesforce should provide a frontend scripting language without support for ajax calls etc. – zuke Nov 4 '15 at 17:30
  • 2
    @zuke I've always envisioned a system where standard pages (e.g. a list view for an object) actually relies on underlying code. Something like this: public class AccountListView overrides Account.ListView { public override ListView.Button[] getListViewButtons(ListView.Button[] configuredButtons) { ... } However, I understand it'd be a lot of work for them to do that, but it could be a powerful system. – sfdcfox Nov 4 '15 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.