/    Sign up×
Community /Pin to ProfileBookmark

HTML button code

What should be a code to use standard HTML button in webpage for downloading files?(downloads starts when click on button(not on hyperlink or image)
I don’t have access to any sort of server-side scripting (PHP, ASP, ColdFusion, etc.). What should be path to file also- local, full ?

Thanks

to post a comment
HTML

13 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Mar 11.2004 — <i>
</i>
&lt;form&gt;
&lt;input type="button" value="Download" onclick="document.location='pathtofiledownload'"&gt;
&lt;/form&gt;
Copy linkTweet thisAlerts:
@TaurusauthorMar 11.2004 — 
  • 1. What should be this 'pathtofiledownload' ? Full url path http://www. sample.com/download/file.zip or local like /home/username/file ?


  • 2. The same question for HTML button code, but for a server which supports only Escapade scripting.


  • [i]Originally posted by crh3675 [/i]

    [B]<i>
    </i>
    &lt;form&gt;
    &lt;input type="button" value="Download" onclick="document.location='pathtofiledownload'"&gt;
    &lt;/form&gt;
    [/B][/QUOTE]
    Copy linkTweet thisAlerts:
    @crh3675Mar 11.2004 — The path would be a qualified URL (http://something)

    The script is simple browser side javascript which should not make a difference on the server
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 12.2004 — the path will work as links. the http:// or similar will send it to a new site, otherwise, it will stay at your server and go to yourserver/whatyoutyped. If you don't put a slash, it will go to yourserver/currentfolders/whatyoutyped.
    Copy linkTweet thisAlerts:
    @fredmvMar 12.2004 — Do not use the suggestion provided above. It's a bad practice to make things such as this rely on JavaScript. Consider the following:&lt;form action="http://www.foo.com/bar.exe" method="get"&gt;
    &lt;div&gt;
    &lt;input type="submit" value="Download" /&gt;
    &lt;/div&gt;
    &lt;/form&gt;
    Though, however, I see nothing wrong with simply providing a link to the file in question&hellip;
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 12.2004 — yet fred's code will add extra line breaks following the submit button, refer to other replies for no line breaks after button.

    Of course, you'd have to add everything you wanted up until the next line break into the div, including tables,forms, graphics, etc. (i recommend the first with location), plus -- that prevents the user from inadvertently pressing the enter/return key.

    EDIT: Possible explanation Fred, many times webmasters do not wanted download links available to general users (notice general in this sentence, check dictionary if must). Buttons prevent one from right clicking, copying the shortcut, and repasting.

    Instead, buttons prevent you from receiving download links because, at least ie does, not redirect if a file is to be downloaded, so the address is never revealed, again to general users.

    Use of javascript has become an immense practice, i wouldn't call it bad, maybe unneccesary.
    Copy linkTweet thisAlerts:
    @fredmvMar 12.2004 — [i]Originally posted by steelersfan88 [/i]

    [B]yet fred's code will add extra line breaks following the submit button, refer to other replies for no line breaks after button.[/B][/QUOTE]
    No &#8212; the other reply is completely incorrect as well as inaccessible. Child elements of forms [b]must[/b] be wrapped in a block-level element. If you wish for there to be no line-break after it, either include the extra markup in which you want within the [font=courier]<div>[/font] container, or use CSS to make it display as an inline-level element.
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 12.2004 — thats why we recommend no forms at all ... less code too.
    Copy linkTweet thisAlerts:
    @fredmvMar 12.2004 — [i]Originally posted by steelersfan88 [/i]

    [B]maybe unneccesary. [/B][/QUOTE]
    Nah. The word you're looking for is [i]inaccessible[/i]. ?[i]Originally posted by steelersfan88 [/i]

    [B]thats why we recommend no forms at all ... less code too.[/B][/QUOTE]
    That's invalid as well as unsemantic.
    Copy linkTweet thisAlerts:
    @ray326Mar 12.2004 — [i]Originally posted by steelersfan88 [/i]

    [B]thats why we recommend no forms at all ... less code too. [/B][/QUOTE]

    Form elements like buttons are not valid outside of a form block so I guess what you're recommending is a non-form element with an onclick handler.
    Copy linkTweet thisAlerts:
    @steelersfan88Mar 12.2004 — i think unneccesary fits my thoughts better, as inaccessible means simple, can[]not be accessed. How does that apply ...

    I hate to go against valid code, but there are thousands of exceptions. This may not be the classic example, but I would never say no to this simple script. Not to put anyone's level of skill here down, but users that are still learning the language should stick to simplicity first, then as they learn, move to validation, making sure not to teach too much invalid code -- as long as its simplistic.
    Copy linkTweet thisAlerts:
    @TaurusauthorMar 12.2004 — I want use HTML button for downloading, I like this way.

    So, the most right solution is:
    ------------------------------------------------------------------


    <form action="http://www.foo.com/bar.exe" method="get">

    <div>

    <input type="submit" value="Download" />

    </div>

    </form>
    -------------------------------------------------------------------


    Is this correct?

    I would like to hear advice on second part of my question still: my host supports Escapade Server-Side Scripting Engine(only this, no anything else) they provide no any support, like how to use this, what is advantages etc(script author, Squishedmosquito.com also does not provide any support at all).)So , I dont know how to use this progressive thing etc. Perhaps, somebody know how to implement this 'modern' script for HTML button
    Copy linkTweet thisAlerts:
    @ray326Mar 12.2004 — That looks fine. I've never heard of that scripting engine so I can't comment on that. The file path needs to be as presented by the web server so "local" is not an option but you can user either a relative or a full URL as presented.
    ×

    Success!

    Help @Taurus spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.7,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...