Help! How Can I Make A Pop Up Window with download link and javascript

Discussion in 'HTML & JavaScript' started by Empire007, Jul 8, 2013.

  1. Empire007

    Empire007 Regular Member

    Jul 22, 2012
    Likes Received:
    Okay, i am not quite good in coding myself, but i have tried to use google to find if i could have an anwser for this but no luck, maybe i am not putting in the right keywords.

    I made a html page, and i want to put a download link and a script, so once the user click the download button image, The download will begin and the script will open in another tab. i dont know how to do it, please your help would be appretiated
  2. Lyscer

    Lyscer Junior Member

    Jun 29, 2012
    Likes Received:
    Software Engineer
    I'm not quite sure what you are referring to with the term "and the script will open in another tab". From a scripting perspective I don't think it is possible to control opening a new tab vs new window because that is a setting in the browser that determines how links are opened.

    If I am over simplifying this then please clarify and I will revise my answer. For your download link you will have something like the following (I chose a random image from google for demonstration):

    javascript_method_to_run would be defined in the <head> of the html
        <script type="text/javascript">
            function javascript_method_to_run(){
                // Code to do something . . .
                // Open a new window to execute code/script on that page
      '', '_blank');
    This would go in the <body>

    <a onclick="javascript_method_to_run();" href="">
        <img src="" alt="Download [FILE_NAME]" title="Download [FILE_NAME] />