简体   繁体   中英

New tab won't open window.open html and js

Trying to code a button in HTML that opens a new tab to a website when clicked. However, when it is pressed, it just leads to a white page and nothing happens. Please give advice on what to do

HTML:

<input type="button" value="Save" onclick="editText()">
<script type="text/javascript" src="edit.js"></script>

<!-- This button is supposed to open a new tab to a website -->
<input type="button" value="Run" onclick="open()">
<script type="text/javascsript" src="edit.js"></script>

Javascript (edit.js):

function editText() {
    document.getElementById("status").innerHTML = "Saved!"
}

function open() {
    window.open("https://www.google.com/?client=safari", _blank)
}

you should pass __blank as string

window.open("https://www.google.com/?client=safari", '_blank')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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