如何使用<a Href>从“ http://”更改为“ file://”

时间:2019-11-06 01:31:45

标签: javascript c# asp.net json hyperlink

在我的代码中使用asp.net实现Java脚本背后的代码中存在问题。单击后要使用超链接,它将为此文件打开新标签页

我已经在Web浏览器中使用过开发人员工具来查看页面源,以显示我的输出。

data += "<td><a href='..\\" + reader["Link"].ToString() + "' target='_blank''>" + reader["FileName"].ToString() + "</a></td>";
开发人员工具的

输出将显示为

http://server001/d$/wwwroot/test_system/SaveAttacmentFolder/test%20PO%2011005488%ABC%2008-01-19.pdf

实际上必须像这样显示

file://server001/d$/wwwroot/test_system/SaveAttacmentFolder/test%20PO%2011005488%ABC%2008-01-19.pdf

2 个答案:

答案 0 :(得分:0)

您可以像这样更改代码

[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: tycho.demo.itp01 1.0.0.qualifier
[ERROR]   Missing requirement: tycho.demo.itp01 1.0.0.qualifier requires 'osgi.bundle; org.eclipse.core.runtime 3.15.300' but it could not be found
[ERROR] 
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
[ERROR] Cannot resolve dependencies of MavenProject: tycho.demo.itp01:tycho.demo.itp01:1.0.0-SNAPSHOT @ /home/frto100/git/org.eclipse.tycho-demo/itp01/tycho.demo.itp01/pom.xml: See log for details -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException

如果data += "<td><a href='file://" + reader["Link"].ToString() + "' target='_blank''>" + reader["FileName"].ToString() + "</a></td>"; 引起了任何问题,您可以使用逃生拖拉机

尝试

/

data += "<td><a href='file://server001" + reader["Link"].ToString() + "' target='_blank''>" + reader["FileName"].ToString() + "</a></td>"; 的值是

reader["Link"].ToString()

附加/d$/wwwroot/test_system/SaveAttacmentFolder/test%20PO%2011005488%ABC%2008-01-19.pdf 应该是

file://server001

答案 1 :(得分:-2)

您可以尝试以下方法:

function http() {

    let str = "http://server001/d$/wwwroot/test_system/SaveAttacmentFolder/test%20PO%2011005488%ABC%2008-01-19.pdf";

    let f = str.replace('http', 'file');

    console.log(f);

}