如何触发 window.open 到特定的动态 URL?

How can I trigger window.open to a specific dynamic URL?

我想打开一个带有已发送条件的新标签,我现在的代码:

<span>Type <b>Link</b>: <input id="myInput" value=""> and click <b>Enter</b> 
<button style="display: none;" id="myButton" onclick="myFunction2()">Go!</button>

[...]

<script>
var websitelink = '"https://www.' + myInput + '.com"';
function myFunction2() {
    window.open(websitelink);
}

但它所做的只是打开一个新的空白标签。有什么想法吗?

谢谢。

您的网站链接中的引用比您需要的多

它应该适用于此:

var websitelink = "https://www." + myValue + ".com";

这是一个片段:

网站中的代码应该可以运行,但代码段将无法运行,因为 iframe 中未设置允许弹出窗口权限

Blocked opening 'https://www.google.es.com/' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.

function myFunction2() {
    var myInput = document.getElementById("myInput").value;
    var websitelink = "https://www." + myInput + ".com";
    window.open(websitelink);
}
<span>Type <b>Link</b>: <input id="myInput" value=""> and click <b>Enter</b> 
<button style="" id="myButton" onclick="myFunction2()">Go!</button>