On a Visualforce page use in LEX I have a Link like this:

    onclick="{! 'sforce.one.navigateToURL(\"/' item['Id'] + '\")' }"

Dual usage of onclick AND href ensures, that it works fine when clicked plus fine if you middle-click, right-click or do something else in the browser with the link. If you go only with navigateToURL() the usability is very very poor.

Now, when I render the page, inspect the generated markup, I get as expected something like

    A Name

Which is perfectly good and exactly how it needs to be.

The bad things start to happen, when I do a right-click. Then Salesforce seems to want to help by changing the href-attribute like this:


Which obviously can't work and leads to a broken and faulty link. Again, this happens very late: at the time, when the link is clicked with the right mouse button - not earlier - not just after the page is rendered. There is a listener on the a-tags doing that rewrite in main.js.

By the way:

  • an immediate middle-click works as expected - this is only on right-click
  • I think it has started with summer'17 and was not happening in spring'17 but I'm not 100% sure


  • why does this happen at all? I see no need, if href a written properly, everything is fine without that. I suspect, that Salesforce is trying to do something good for old VF-pages which are not aware of LEX and come with bad hrefs, like only "/0010Y00000K6lJ5" or "/0010Y00000K6lJ5/e"
  • how can I prevent this this feature from crippling my hrefs? How can I turn this behavior off OR how can I write my hrefs in order to work (as described) and being immune against this interaction?
  • 1
    As for prevention, you may need to implement MutationObserver. – Adrian Larson Jun 22 '17 at 11:54
  • 1
    @AdrianLarson : I found already a workaround by adding my own listener on the "contextmenu" event, which is basically just undoing the rewrite. Luckyly it will fire after the salesforce-handler and I can reliably cleanup the mess. But I would prefer something cleaner. – Uwe Heim Jun 22 '17 at 11:57

Your Answer

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

Browse other questions tagged or ask your own question.