href=“file://” doesn't work

后端 未结 4 1152

I have a problem with: href=\"file://\" Well I want to point a link in html to file, in browser if I write like

 file:///K:/filename.pdf
         


        
4条回答
  •  猫巷女王i
    2020-12-17 00:38

    The reason your URL is being rewritten to file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf is because you specified http://file://

    The http:// at the beginning is the protocol being used, and your browser is stripping out the second colon (:) because it is invalid.

    Note

    If you link to something like

    yourfile.pdf
    

    The above represents a link to a file called k:/yourfile.pdf on the k: drive on the machine on which you are viewing the URL.

    You can do this, for example the below creates a link to C:\temp\test.pdf

    test.pdf
    

    By specifying file:// you are indicating that this is a local resource. This resource is NOT on the internet.

    Most people do not have a K:/ drive.

    But, if this is what you are trying to achieve, that's fine, but this is not how a "typical" link on a web page works, and you shouldn't being doing this unless everyone who is going to access your link has access to the (same?) K:/drive (this might be the case with a shared network drive).

    You could try

    test.pdf
    test.pdf
    test.pdf
    

    Note that http://file:///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf is a malformed

提交回复
热议问题