我想通过网址显示JavaScript

时间:2018-09-02 10:01:45

标签: javascript java html node.js ajax

我想显示这个,但是它不能正常工作。

document.write('<a href="/site"><img src="" alt="image"/></a> var answer = 
confirm ("Please click on OK to continue loading my page, or CANCEL to be 
directed to the Yahoo site.")
if (answer)
    window.location="https://www.google.co.in";');      

1 个答案:

答案 0 :(得分:0)

文档和脚本是如此不同。 如果打开访问页面时确认,则可以。

<script>
    window.onload = function() {
        var answer = confirm ("Please click on OK to continue loading my page, or CANCEL to be directed to the Yahoo site.");
        if (answer) window.location="https://www.google.co.in";
    }
</script>