-3
<script>
function password(){
    alertify.prompt("INGRESE LA CLASE", function (e, str) {
        if (str=='123'){ 
            // here! how to get into the another page, like "index.html"
        } else {
            alertify.log('ERROR! INGRESE LA CLAVE');
        } 
    }); 
}
</script>

<a href="index.html" onClick="password(); return false;">AQUI</a>

它可以使用 Alertify,但是在 OK 之后,需要一些代码来打开页面索引。

4

2 回答 2

0

使用 window.location 你可以做到这一点。window.location = "index.html";

于 2014-07-03T22:12:38.567 回答
0

如果您想要的是该函数将当前页面重定向到单击链接的 href 属性中的页面,那么

<script>
function password(event){
    alertify.prompt("INGRESE LA CLASE", function (e, str) {
        if (str=='123'){ 
            // here! how to get into the another page, like "index.html"
            window.location.href = event.target.href;
        } else {
            alertify.log('ERROR! INGRESE LA CLAVE');
        } 
    }); 
}
</script>
<a href="index.html" onClick="password(event); return false;">AQUI</a>

这将重定向到您在 href 上的任何页面,index.html 或其他任何页面。我不会推荐这种方法,虽然......

于 2014-07-04T01:03:34.543 回答