javascript - 使用javascript在另一个页面中打开一个html文件
问题描述
我想在javascript中使用打开一个新窗口。我已经使用 window.open() 函数完成了这项工作。如此处所见
var opened = window.open("");
opened.document.write("<p>helloWorld</p>");
我可以让函数打开一个 html 文件,而不是将我的 html 代码作为参数写在 opens.document.write() 函数中。
解决方案
如果 html 是静态的,您只需将其托管在您的网络服务器上的不同路径。
那么你只需要使用window.open("/path/to/html/file.html")
这是有关使用 window.open() https://developer.mozilla.org/en-US/docs/Web/API/Window/open的更多信息
推荐阅读
- struct - 可区分联合的结构属性
- linux - 复制文件而不删除目标功能
- python - 在特定深度的 dict 上添加项目
- julia - 如何在两个for循环中使用break?
- sql-server - 如何获取每组中的最后一行
- c - c 的 if、switch 和 while 条件中的 print 语句
- python - *为什么*不是 run_until_complete 可重入。如何在没有线程的情况下逐步移植到异步?
- sql-server - 将具有不同列的多个表合并到一个表中
- graphql - GraphQL 查询 ID 以外的内容
- apache-camel - 使用 Camel RoutePolicy 设置 sqs 的高优先级/低优先级路由消费者的优雅方法?