SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Auto Download

  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Location
    Fayetteville, AR
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto Download

    Hello,

    I'm having problems creating a small JavaScript snippet that will automatically start a file download when a page loads. I managed to create a script that worked in Firefox but would not work in most versions (most current versions, atleast) of IE because of the SP2 pop-up blocker, I believe. I'm hoping to find a solution that doesn't involve popping up a new window entirely, but just have the download prompt pop-up once the page is loaded.

    For example...you visit downloadpage.html and you are prompted to download the file Install.exe right when the page loads, without using new windows all together. Anyone have any JavaScript code that can help me accomplish this? Thanks!

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post your Firefox script so we can try and modify it appropriately?

    Thanks!

    Dave

  3. #3
    SitePoint Member
    Join Date
    Apr 2005
    Location
    Fayetteville, AR
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Dave! The following code works great in Firefox, but the Windows SP2 pop-up blocker kills the download prompt when viewing the page in any recent version of IE, which is my main target browser, really.

    Code:
        <script type="text/javascript">
    
            if (!document.readyState)
            {
            var dl='<m'+'et'+'a ht'+'tp-eq'+'uiv="Ref'+'r'+'esh" con'+'tent="0;UR'+'L='+'ht'+'tp://w'+'ww.do'+'main.com'+'/Install.exe"/>';
            document.write(dl);
            }
    
        </script>
    I didn't write this code, I found it somewhere online...any help would be GREATLY appreciated, thanks!

  4. #4
    SitePoint Member
    Join Date
    Apr 2005
    Location
    Fayetteville, AR
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2006
    Location
    England, UK
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    couldnt you simply do a redirect?

  6. #6
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (!document.readyState)

    Know: ie4-9, op 7-9 kq3+
    Dont know: FF, NN, op4-6


Bookmarks

Posting Permissions

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