Pathik_Joshi
Pathik_Joshi

Reputation: 27

HTML: method attribute in anchor tag

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?

Upvotes: 2

Views: 1332

Answers (2)

BenM
BenM

Reputation: 53246

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.

Upvotes: 3

Marcos P&#233;rez Gude
Marcos P&#233;rez Gude

Reputation: 22158

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>

Upvotes: -1

Related Questions