# Run the JavaScript code on a web page from the shortcut in my file?

MWE

\documentclass[a4paper,11pt]{article}
\usepackage{color}
\usepackage[hyphens]{url}
\begin{document}
%\href{https://edu.casio.com/education/activity/fx991esplus.pdf}{fx991esplus.pdf}
\end{document}


How do I direct a JavaScript shortcut like this from within a file?

javascript:DownloadSubmit(%20'146'%20,%20'fx991esplus.pdf'%20,%20'1'%20)

Is something like this possible?

Information I learned EDIT-1

1) javascript:DownloadSubmit() It had a function.

2) I tried to apply it as html first. Good working.

<form action="https://edu.casio.com/education/activity/download.php" method="post">
<input value="Submit" type="submit" />
</form>


3) MWE

\documentclass{article}
\usepackage[pdftex]{insdljs}
\usepackage[pdftex]{eforms}

\begin{document}

\Submit{Submit}
\end{Form}
\end{document}


Hyperlinks don't work with Reader 9. Solution, Latest reply on May 17, 2013 7:13 AM by poisson02 . Edit>Preferences>Trust Manager>Change Settings>Allow all web sites

Now

pdftk <filename>.pdf dump_data_fields

---
FieldType: Text
FieldName: dl_FILE_NO
FieldFlags: 1
FieldValue: 146
FieldJustification: Left
---
FieldType: Text
FieldName: dl_FILE_NAME
FieldFlags: 1
FieldValue: fx991esplus.pdf
FieldJustification: Left
---
FieldType: Text
FieldName: dl_FILE_CD
FieldFlags: 1
FieldValue: 1
FieldJustification: Left
---
FieldType: Button
FieldName: Submit
FieldFlags: 65540
FieldJustification: Left


Where am I doing wrong? How can I fix?

EDIT-2

\begin{Form}[action={http://edu.casio.com/education/activity/download.php},method=post]

\begin{Form}[action={https://edu.casio.com/education/activity/download.php},method=post]

Now

• Your question is very unclear. What do you want to do? – Paul Gaborit Aug 24 '17 at 14:49
• The file is not stored somewhere like ftp. My aim is to show a shortcut from my pdf file and download it directly. I would like to add such a JavaScript code to the file. And when I click on it, I want to download the file. Is that enough? – Özgür Aug 24 '17 at 14:59
• Nothing to do with (La)TeX... Without an URL you can't do anything. – Paul Gaborit Aug 24 '17 at 22:15

This LaTeX source will generate the desired URL.

\documentclass[a4paper,11pt]{article}
\usepackage{color}
\usepackage[hyphens]{url}
\begin{document}
\end{document}


The result (when you hover over the link) is:

Notice however, as stated by Paul Gaborit in his comment, that following the link (e.g., from a PDF file) will not work. This could only work if the link is included in HTML source that also contains the required Javascript code. If you're not thinking of using an HTML backend for LaTeX, you may be in the wrong track here.

EDIT: A different approach would be to observe what the Javascript code on the Casio page is doing and do the same in your LaTeX file. If it finally issues a GET request for a document, needing no extra cookies or session information, then you're lucky. In your case, what it does is a (relatively simple, I think) POST request to https://edu.casio.com/education/activity/download.php with data such as:

dl_FILE_NO:146
dl_FILE_NAME:fx991esplus.pdf
dl_FILE_CD:1


I believe that hyperref can handle POST requests. Check its documentation (§6.1).

• I'll check documentation. – Özgür Aug 30 '17 at 7:52
• §6.1 of the current hyperref documentation (Jan. 2017). However, this is for forms, I'm not sure if it's good for you. – nickie Aug 30 '17 at 8:44
• Please, see the edited my question. – Özgür Sep 2 '17 at 14:46
• I still don't see what you're trying to do. Say you succeed in posting and the Casio site responds by sending you a PDF. What do you want your PDF viewer to do? I doubt it can handle such a response, therefore the message you're receiving. – nickie Sep 9 '17 at 12:00
• Dear nickie, after you write, especially §6.1, it was very useful for me. I try to do, to download a file by clicking on a link in PDF. In the meantime I have done a lot of research on the internet to see if the problem is LaTeX or any other problem. I even made javascript in the PDF editor. I also wrote this problem on the Adobe forum. I think there's something wrong with the PDF viewer. Clicking the shortcut makes the data exchange but fails to download the file. – Özgür Sep 9 '17 at 15:16