How to run an external program, e.g. notepad, using hyperlink?
Try this
<html>
<head>
<script type="text/javascript">
function runProgram()
{
var shell = new ActiveXObject("WScript.Shell");
var appWinMerge = "\"C:\\Program Files\\WinMerge\\WinMergeU.exe\" /e /s /u /wl /wr /maximize";
var fileLeft = "\"D:\\Path\\to\\your\\file\"";
var fileRight= "\"D:\\Path\\to\\your\\file2\"";
shell.Run(appWinMerge + " " + fileLeft + " " + fileRight);
}
</script>
</head>
<body>
<a href="javascript:runProgram()">Run program</a>
</body>
</html>
Open an exe file through a link in a HTML file?
You can not start/execute an .exe file that resides locally on the users machine or through a site. The user must first download the exe file and then run the executable.
Idea's to launch an application (with parameters) from a pdf document
Action dictionary of Link annotation can have Win sub-dictionary with P key, containing "parameter string to be passed to the application". It looks like Acrobat is handicapped and doesn't allow to add/edit Win dictionary entries. You can use freeware PDF-XChange Viewer for that. E.g., I added a link to launch Notepad with a parameter, here's result (pretty-printed with mutool):
12 0 obj
<<
/A <<
/F 30 0 R
/S /Launch
/Win <<
/F (C:\\WINDOWS\\notepad.exe)
/O (open)
/P (/A c:\\boot.ini)
>>
>>
...
How to open link in a new tab in HTML?
Set the target
attribute of the link to _blank
:
<a href="#" target="_blank" rel="noopener noreferrer">Link</a>
For other examples, see here: http://www.w3schools.com/tags/att_a_target.asp
Note
I previously suggested blank
instead of _blank
because, if used, it'll open a new tab and then use the same tab if the link is clicked again. However, this is only because, as GolezTrol pointed out, it refers to the name a of a frame/window, which would be set and used when the link is pressed again to open it in the same tab.
Security Consideration!
The rel="noopener noreferrer"
is to prevent the newly opened tab from being able to modify the original tab maliciously. For more information about this vulnerability read the following articles:
- The target="_blank" vulnerability by example
- External Links using target='_blank'
Related Topics
How to Force a Long String Without Any Blank to Be Wrapped
Fixed Header, Footer With Scrollable Content
Unwanted Margin in Inline-Block List Items
Example of Multipart/Form-Data
How to Support Placeholder Attribute in Ie8 and 9
Maintain Image Aspect Ratio When Changing Height
Using CSS :Before and :After Pseudo-Elements With Inline Css
How to Close ≪Img≫ Tag Properly
Having Google Chrome Repeat Table Headers on Printed Pages
What Is the Functionality of !Doctype
Why Does Margin-Top Work With Inline-Block But Not With Inline