tags:

views:

48

answers:

1

I know I can use

a[href$='.mov'] 

to check if the href refers to a .mov file.

However, can I generally check if the href attribute refers to a file?

So any file with a suffix at the end?

Regards Matt

+1  A: 

You can't tell from URL, and also the definition of a file is subjective. Technically, index.html is a file, but probably not a file from the prospective of your question.

If you had a list of known file extensions you wanted to select, you could do something like this

a[href$='.mov'],
a[href$='.exe'] {
    color: red;
} 

Otherwise if you had a server side language, you could follow the links and look for download response headers (look for Content-Disposition: inline) though this is also probably way too much overhead and a bad idea.

I don't think the look for any link with extension is a good idea to determine if it links to a file. You probably want a whitelist, and check against that.

alex
alright, got it! i'll find a different solution. dumb question in the first place. of course html-documents are files too. sorry for the question!
@mathiregister Don't be sorry! If you learned something, I guess it was worthwhile :)
alex