Soul Coder
Soul Coder

Reputation: 804

How to click button automatically when redirect from another page in javascript or jquery?

I have two files, which is index.html and myfile.html,in index.html there is a link to redirect another page like Download and in myfile.html file, there is a button like

<button onClick="$('.table').tableExport({type:'excel',escape:'false'});" class="btn btn-default btn-xs pull-right"><i>Excel</i></button>

If user click this button from myfile.html, excel file will be download.So its two steps right? What I want to do is like when user click a link from index.html, I want to download directly, like opening another page and downloading the file. Is there anyway to do like this?

Upvotes: 2

Views: 1833

Answers (1)

Sagar Jajoriya
Sagar Jajoriya

Reputation: 2375

Give a selector to the download button and trigger the click event when user redirect to the myfile.html. Like :

On load of the myfile.html, put this script on that

$("download_button_selector").trigger("click");

Upvotes: 1

Related Questions