特定目录包含html文件列表。如何使用JavaScript单击链接从特定目录打开html文件?
答案 0 :(得分:1)
就像建议一样,这会在同一个窗口中打开新的html
<a href="other_directory/no_js_needed.html">Link</a>
这将在新窗口中打开html
<a href="other_directory/no_js_needed.html" target="_blank">Link</a>
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" onclick="window.open(this.href);return false">Link</a>
脚本标记功能中的javascript
<script>
function openlink(link){
location.href=link;
}
openlink('other_directory/no_js_needed.html');
</script>
新窗口中的脚本标记功能中的javascript
<script>
function openinnewwindow(link){
window.open(link)
}
openinnewwindow('other_directory/no_js_needed.html');
</script>