How to add target=“_blank” to JavaScript window.location?

up vote
33
down vote
accepted
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 done = false;
    var key = document.tokey.key.value.toLowerCase();
    if (key == "smk") {
        window.open('http://www.smkproduction.eu5.org','_blank');
        done = true;
    }
    if (done)
        alert("Kodi nuk është valid!");
}

 

posted on 2016-01-17 14:17  阿卡贝拉  阅读(218)  评论(0)    收藏  举报