简体   繁体   English

如何在不单击链接/按钮的情况下以html打开网页

[英]How to open a webpage in html without clicking a link/button

Before I start I would like to say that I am completely new to HTML and have limited programming experience however I am doing a school project and need to understand how to do this. 在开始之前,我想说我对HTML完全陌生,并且编程经验有限,但是我正在做一个学校项目 ,需要了解如何做到这一点。 I have looked everywhere but couldn't seem to find any answers so I came here. 我到处都看了,但似乎找不到任何答案,所以我来到了这里。

I need to know how to get a html script to open a new webpage without external inputs (such as pressing a link). 我需要知道如何获取html脚本来打开没有外部输入(例如按链接)的新网页。 Below are a few of the simple things I have tried to do to open google using html. 以下是一些我尝试使用html打开google的简单操作。

This can very easily be done with: 这很容易做到:

window.location.href = "[URL_HERE]";

No click event is required, just run the line of code when you want to change the URL. 不需要单击事件,只需在要更改URL时运行代码行即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM