Problem using button for download

J

justaguy

Hi,

I don't know why the following code would fail with Firefox and other
browsers.
<input type="button" id="s" value="Download the Software"
onclick="document.location.href('/download/Software2U.exe');"
style="font-size:13pt;background-color:gold">

Thanks.
 
R

RobG

Hi,

I don't know why the following code would fail with Firefox and other
browsers.
<input type="button" id="s" value="Download the Software"
onclick="document.location.href('/download/Software2U.exe');"
style="font-size:13pt;background-color:gold">

Because document.location.href isn't a function so calling it will
cause an error. It's a property to which you can assign a value.
 
J

justaguy

The JavaScript code is apparently in error. A more interesting question
is why you are doing this. To exclude users with JavaScript enabled, or
to prevent search engines from seeing a link?

The normal approach is a normal link, like

<a href=/download/Software2U.exe>Software 2U (executable)</a>

You might style it (maybe to look like a button, but why?), but it is
difficult to see what added value you might get by _not_ making it a
link and making it a JavaScript-only pseudo-link.

You're correct, Jukka, the notion of using button is to make it look a
bit nicer, really gimmick stuff and yet many people under 30 (my
target customer base) are much drawn to such things...
 
A

Arno Welzel

Am 2011-07-19 16:30, schrieb justaguy:
You're correct, Jukka, the notion of using button is to make it look a
bit nicer, really gimmick stuff and yet many people under 30 (my
target customer base) are much drawn to such things...

Then show an *image* of a button, which is linked to the file.

A button will not work, if JavaScript is not enabled - and many younger
people may use stuff like NoScript etc..
 
T

Thomas 'PointedEars' Lahn

Arno said:
Am 2011-07-19 16:30, schrieb justaguy:

Then show an *image* of a button, which is linked to the file.

A button will not work, if JavaScript is not enabled - and many younger
people may use stuff like NoScript etc..

Another possibility is a real button, either

<form action="/download/Software2U.exe">
<input type="submit" value="Software 2U (executable)">
</form>

or

<form action="/download/Software2U.exe">
<button type="submit">Software 2U (executable)"</button>
</form>

or

<form action="/download/Software2U.exe">
<input type="image" src="foo.gif" alt="Software 2U (executable)">
</form>


This way it would be a button even without CSS, and it would work without JS
as well. CSS can make use of the sprite technique, though, which can reduce
the number of requests and make Web sites faster as a result.


PointedEars
 
J

justaguy

Another possibility is a real button, either

  <form action="/download/Software2U.exe">
    <input type="submit" value="Software 2U (executable)">
  </form>

or

  <form action="/download/Software2U.exe">
    <button type="submit">Software 2U (executable)"</button>
  </form>

or

  <form action="/download/Software2U.exe">
    <input type="image" src="foo.gif" alt="Software 2U (executable)">
  </form>

This way it would be a button even without CSS, and it would work withoutJS
as well.  CSS can make use of the sprite technique, though, which can reduce
the number of requests and make Web sites faster as a result.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

Good thought, thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top