如何重定向另一个页面 [英] how to redirect another page

查看:90
本文介绍了如何重定向另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var r=confirm("Press a button!");
if (r==true)
  {
  window.Location="http://www.yahoo.com";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>




我可以按OK按钮重新定向吗?
如果是,那怎么办?


如果没有,请给我另一种方式在我的aspx页面中显示弹出窗口,然后按确定"按钮需要打开另一页面


请帮助我> ...




can i redirect on the ok buton press???
if yes then how?


if no then plz give me another way to show popup in my aspx page and on press ok button need to open another page


plz help me out>...

推荐答案

请替换此脚本
 <script>
        function myFunction() {
            var x;
            var r = confirm("Press a button!");
            if (r == true) {
                location.href = "http://www.yahoo.com";
            }
            else {
                x = "You pressed Cancel!";
            }
            document.getElementById("demo").innerHTML = x;
        }
</script>

无需在此处编写服务器端代码:P

no need to write a server side code here :P


在函数中使用以下内容!而不是window.location();
use the following in your function! instead of window.location();
response.redirect("www.yahoo.com")


这篇关于如何重定向另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆