2

I read in a book, that a methods attribute is available on a hyperlink to link to an executable file from within a webpage.

<a methods="C:\san\proj.exe">Open This Software</a>

But this code is not working on my browser. Does such an attribute exist?

Gerrit Bertier
  • 4,101
  • 2
  • 20
  • 36
  • http://www.w3schools.com/tags/tag_a.asp not that I can see here, also I would be interested to know which book this is – Harry Dec 23 '15 at 08:54
  • 1
    I know the 'method' attribute on a form or the 'formmethod' on an input but never heard of the 'methods' attribute on an anchor. Maybe you need to buy another book ;) – Bas Slagter Dec 23 '15 at 08:55

2 Answers2

3

The methods attribute is extremely out-of-date. For example, it is mentioned in the 1995 W3C Archive for Anchor Elements as follows:

METHODS
OPTIONAL. The value of this field is a string which if present must be a comma separated list of HTTP METHODS supported by the object for public use.

However, it is no longer part of the specification, which likely explains why your browser is not behaving as you expect. For example, the W3C Spec now states the following permitted attributes for <a> elements:

<!ELEMENT A - - (%inline;)* -(A)       -- anchor -->
<!ATTLIST A
  %attrs;                              -- %coreattrs, %i18n, %events --
  charset     %Charset;      #IMPLIED  -- char encoding of linked resource --
  type        %ContentType;  #IMPLIED  -- advisory content type --
  name        CDATA          #IMPLIED  -- named link end --
  href        %URI;          #IMPLIED  -- URI for linked resource --
  hreflang    %LanguageCode; #IMPLIED  -- language code --
  rel         %LinkTypes;    #IMPLIED  -- forward link types --
  rev         %LinkTypes;    #IMPLIED  -- reverse link types --
  accesskey   %Character;    #IMPLIED  -- accessibility key character --
  shape       %Shape;        rect      -- for use with client-side image maps --
  coords      %Coords;       #IMPLIED  -- for use with client-side image maps --
  tabindex    NUMBER         #IMPLIED  -- position in tabbing order --
  onfocus     %Script;       #IMPLIED  -- the element got the focus --
  onblur      %Script;       #IMPLIED  -- the element lost the focus --
  >

As a general rule, you cannot run executable scripts directly from a web browser (thankfully). The only option you have is to link directly to the exe file using the anchor's href attribute, and have the visitor download the file via their browser. It is then their decision if they chose to run the executable or not. This would be achieved as follows:

<a href="C:\san\proj.exe">Open This Software</a>

It is worth noting that the path you've specified here (i.e. C:\sans\... is a local path, and will need to be modified when your project becomes available online.

BenM
  • 52,573
  • 26
  • 113
  • 168
-1

You need to specify the protocol. In your case is file:// but I don't recommend to link to your hard disk if you publish the webpage in http://

The correct attribute is href:

 <a href="file://C:\san\proj.exe">Open This Software</a>
Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
  • *Don't recommend linking to your hard disk if you publish the webpage*? How would that work then, using `file://`? – BenM Dec 23 '15 at 09:00
  • If the webpage is published anywhere other than a local server, the `file://C:\san\` URL will try to to look for a file on the visitor's local machine, so no, it's not true. – BenM Dec 23 '15 at 09:03
  • If the webpage is under `file://` protocol, there aren't no servers running. But your point about visitor's machine is true. That doesn't converts my answer in false. – Marcos Pérez Gude Dec 23 '15 at 09:08
  • But you specifically stated that you don't *recommend* using `file://` with `http://` when it's published on the open web... – BenM Dec 23 '15 at 09:09