Results 1 to 3 of 3

Thread: Help With JavaScript Automatic Download Injection

  1. #1
    Join Date
    May 2014

    Question Help With JavaScript Automatic Download Injection


    I have been asked if I could make a small piece of code that would download a specific file off a website automatically, however as I have little to no background in web dev I was wondering if someone could please help? I trowled through google a bit and didn't find anything relating specifically to what I need to do so here I am.

    Basically I have been asked to download the file on this website, when you press the "Export" button in the right hand side and then the "Export" button on the form that appears which then initates a download of the file "PracticeProfiles.xls".

    I got the first part, by issueing "javascript:showExport()", however am now a little lost from there..

    I had a look at the wesite and this file seems to be generated as oposed to having a hard link somewhere to it on the server (I may be wrong).

    Can anyone suggest how I would achieve this using JavaScript Injections please?

    Many Thanks


  2. #2
    Join Date
    Mar 2007
    After poking around the JavaScript, I can see that they are using a mix of JavaScript and JQuery to do some of the leg work.

    My suggestion is to look at the JavaScripting to find the polling URL that causes the file generation and try a server-side cURL poll or similar to pull the data off the server.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Cheap trick -- make an anchor that links to the file in javascript... then call it's click() method.

    var a = d.body.appendChild(d.createElement('a'));
    You have to append it to body or Firefox and Chrome ignores it, though "real" Opera and IE will obey it without the appendChild... Since it has no text in it, the appendChild is usually safe... though you might want to detect if you already have one so if there are multiple downloads you don't fill up the DOM with empty anchors.
    Last edited by deathshadow; 06-01-2014 at 11:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center