[SalesForce] HTMLElement.click() not working in IE10 for custom button

I created a custom button on the Quote object that executes JavaScript, and everything works fine except for a critical call to HTMLElement.click(). The kickers to this problem are:

  • The button works fine in Firefox and Chrome, just not in IE10
  • The same code works when I run it from IE10's developer tools Console

Does anyone have any ideas why this is happening? And any workarounds?

I can reproduce the problem consistently via the following steps:

  1. Create and activate at least two new quote templates, e.g., "United States Standard Template" and "United Kingdom Standard Template"
  2. Create a custom button on the Quote object labeled "Create My PDF", which executes the following JavaScript: document.getElementById("createpdf").click();
  3. Add the custom button to an applicable Quote page layout, making sure the standard Create PDF is also present
  4. Open IE10, and on a Quote detail page, click the Create My PDF button. Nothing happens. But if you press F12 and run the exact same JavaScript in the Console, it works as expected.

Best Answer

After digging deeper into the standard Create PDF button, I discovered a hidden anchor element that contained the actual JavaScript call for selecting a template. I modified my code to click this anchor tag instead, using jQuery.

Related Topic