Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript从目录新窗口打开html文件_Javascript_Html - Fatal编程技术网

如何使用javascript从目录新窗口打开html文件

如何使用javascript从目录新窗口打开html文件,javascript,html,Javascript,Html,特定目录包含html文件列表。如何通过使用JavaScript单击链接从特定目录打开html文件?如建议的,这将在同一窗口中打开新的html <a href="other_directory/no_js_needed.html">Link</a> 这将在新窗口中打开html <a href="other_directory/no_js_needed.html" target="_blank">Link</a> <a href="oth

特定目录包含html文件列表。如何通过使用JavaScript单击链接从特定目录打开html文件?

如建议的,这将在同一窗口中打开新的html

<a href="other_directory/no_js_needed.html">Link</a>

这将在新窗口中打开html

<a href="other_directory/no_js_needed.html" target="_blank">Link</a>
<a href="other_directory/no_js_needed.html" onclick="window.open(this.href);return false">Link</a>
<script>
function openinnewwindow(link){
window.open(link)
}
openinnewwindow('other_directory/no_js_needed.html');
</script>

javascript内联方式同一窗口

<a href="other_directory/no_js_needed.html" onclick="location.href=this.href;return false">Link</a>

javascript内联新窗口

<a href="other_directory/no_js_needed.html" target="_blank">Link</a>
<a href="other_directory/no_js_needed.html" onclick="window.open(this.href);return false">Link</a>
<script>
function openinnewwindow(link){
window.open(link)
}
openinnewwindow('other_directory/no_js_needed.html');
</script>

脚本标记函数中的javascript

<script>
function openlink(link){
location.href=link;
}
openlink('other_directory/no_js_needed.html');
</script>

函数openlink(link){
location.href=link;
}
openlink('other_directory/no_js_needed.html');
新窗口中脚本标记函数中的javascript

<a href="other_directory/no_js_needed.html" target="_blank">Link</a>
<a href="other_directory/no_js_needed.html" onclick="window.open(this.href);return false">Link</a>
<script>
function openinnewwindow(link){
window.open(link)
}
openinnewwindow('other_directory/no_js_needed.html');
</script>

函数openinnewwindow(链接){
窗口。打开(链接)
}
openinnewwindow('other_directory/no_js_needed.html');

为什么需要javascript?您只需要标签
还有,
“java”!=“javascript”
。我已经相应地编辑了标签。真的,你只是要复制并粘贴我的评论?!我写了6种不同的方法。。。如果我使用你的“other_directory/no_js_needed.html”有什么问题吗?在你的评论中,我只看到target是空的。如果我们想谈论你的评论,他会问javascript而不是html。哈哈,我只是说你的第二个例子是我评论的直接复制和粘贴。我并不是说这是革命性的,但你不能否认你做到了。我是新来的,只是想帮助ppl,如果他问如何链接到一个文件,他需要更多的解释