How to add target=“_blank” to JavaScript [removed]?

后端 未结 4 792
渐次进展
渐次进展 2020-11-28 03:05

The following sets the target to _blank:

if (key == \"smk\") {
    window.location = \"http://www.smkproduction.eu5.org\";
    target = \"_blank         


        
4条回答
  •  醉话见心
    2020-11-28 03:51

    window.location sets the URL of your current window. To open a new window, you need to use window.open. This should work:

    function ToKey(){
        var key = document.tokey.key.value.toLowerCase();
        if (key == "smk") {
            window.open('http://www.smkproduction.eu5.org', '_blank');
        } else {
            alert("Kodi nuk është valid!");
        }
    }
    

提交回复
热议问题