0

How i can simulate click on a multiple buttons from client side controller of the Lightning Aura Component?

2
  • 1
    Hello and welcome. Could you please add some sort of markup/code to better understand what you are trying to achieve? Commented Nov 14, 2019 at 19:46
  • I am trying to download attachments at URL. I can't share the code due to IP policy of the company. I know it can be done with <a> tag, however I need solution for mass download. Commented Nov 14, 2019 at 19:49

1 Answer 1

2

You use the Element click method. Here's an example:

var a = document.createElement('a');
a.href = 'some file url';
a.click();

Note that browsers will typically block this type of script unless the user clicks a button. You might not be able get a "mass downloader" working in any modern browser because of this restriction.

4
  • Can I loop through the urls and fire it within loop? Commented Nov 14, 2019 at 23:58
  • @ShohraiMuhamov You can write such code, but if it works will depend on browser settings and security settings.
    – sfdcfox
    Commented Nov 15, 2019 at 0:58
  • Can I use same method to download audio files such as mp3 or wav, or is there another way of doing it for them? Commented Nov 15, 2019 at 16:39
  • Using for loop worked for mass download for me! Kudos @sfdcfox ! Commented Nov 15, 2019 at 21:47

Not the answer you're looking for? Browse other questions tagged .