Javascript:通过弹出窗口重定向到另一个网页

Javascript:通过弹出窗口重定向到另一个网页,javascript,redirect,popup,sandbox,Javascript,Redirect,Popup,Sandbox,我对Javascript非常不熟悉,我无法找到需要帮助的解决方案。我有一个网站,我试图重定向到另一个网站,但通过弹出窗口 例如: <script>alert(This will prompt up the message)</scrip> <script>window.location="http://This-will-redirect-me-to-another-link.com";</scrip> 警报(这将提示消息) window.lo

我对Javascript非常不熟悉,我无法找到需要帮助的解决方案。我有一个网站,我试图重定向到另一个网站,但通过弹出窗口

例如:

<script>alert(This will prompt up the message)</scrip>

<script>window.location="http://This-will-redirect-me-to-another-link.com";</scrip>
警报(这将提示消息)
window.location=”http://This-will-redirect-me-to-another-link.com";
正如你所看到的,我可以简单地使用第二个javascript将用户重定向到另一个页面,但由于某些原因,我无法使用它,因为它只对页面的一半起作用(脚本有点像“沙盒”),但如果我弹出一个窗口(第一个警报脚本),第二个脚本将从“沙盒”中退出。有没有人对我应该如何实现这一点有任何想法,或者可以用PHP或HTML实现


谢谢你的两个回复,尽管我很确定你的帮助会帮助我,但是这些都没有帮助我。我有一个MyBB论坛,有一个我正在使用的shoutbox。有一个命令可以改变shoutbox的通知,这个命令是/notice New notice |但是我注意到新通知可以用javascript更改,它可以像/notice js代码一样工作|然后我想如果我制作这样一个javascript,将人们重定向到另一个网页会怎么样。因为我有这样一个论坛,它需要从主页重定向到另一个,我想应用它。然后工作人员可以在论坛上做得很好,但是有一个问题。加入

/注意窗口。位置=”http://This-will-redirect-me-to-another-link.com"; 这只会影响shoutbox,shoutbox被重定向到另一个网页,但由于警报对整个论坛有效,我想也许我可以用警报将它们重定向到其他地方。我想知道的是,是否只有一个脚本,然后工作人员就可以做到这一点。我知道这是一个严重的安全风险&也可能是其他风险,但我真的很想尝试一下


我希望有人能帮忙。:)

使用Confim和capture响应重定向。此弹出窗口将显示两个按钮-确定和取消

if(confirm("Popup Message")){
   window.location = "your intended destination";
}else {//do nothing. This will fire if cancel is clicked.}

使用Confim和capture response重定向。此弹出窗口将显示两个按钮-确定和取消

if(confirm("Popup Message")){
   window.location = "your intended destination";
}else {//do nothing. This will fire if cancel is clicked.}

这样就可以了,但是用户要执行什么触发器来实现重定向呢? 我还想说,使用jQuery对话框比使用警报框要好得多 在HTML的头部

<script>
function changePage(whereToGo, messageText)
{
    alert(messageText);
    window.location=whereToGo;
}
</script>

功能更改页(其中,转到,messageText)
{
警报(messageText);
window.location=whereToGo;
}
然后是HTML本身

<script>changePage("http://This-will-redirect-me-to-another-link.com", "The message you want to show");</script>
changePage(“http://This-will-redirect-me-to-another-link.com“,“您要显示的消息”);
注意所有错误检查的完成情况

好的,那就试试这个

<script>
alert("Whatever you want to say") && window.location="http://yourwebsitehere.com";
</script>

警报(“你想说什么就说什么”)&&window.location=”http://yourwebsitehere.com";

这将在一条语句中执行这两个操作,这样就可以了,但是用户要执行什么触发器来实现重定向呢? 我还想说,使用jQuery对话框比使用警报框要好得多 在HTML的头部

<script>
function changePage(whereToGo, messageText)
{
    alert(messageText);
    window.location=whereToGo;
}
</script>

功能更改页(其中,转到,messageText)
{
警报(messageText);
window.location=whereToGo;
}
然后是HTML本身

<script>changePage("http://This-will-redirect-me-to-another-link.com", "The message you want to show");</script>
changePage(“http://This-will-redirect-me-to-another-link.com“,“您要显示的消息”);
注意所有错误检查的完成情况

好的,那就试试这个

<script>
alert("Whatever you want to say") && window.location="http://yourwebsitehere.com";
</script>

警报(“你想说什么就说什么”)&&window.location=”http://yourwebsitehere.com";

这将在一句话中完成两个动作

谢谢你们两位的回复,但不幸的是,他们目前无法帮助我。我用新的信息编辑了这个问题,希望它能帮助您帮助我制定一些解决方案。:)谢谢你们两位的回复,但不幸的是,他们目前无法帮助我。我用新的信息编辑了这个问题,希望它能帮助您帮助我制定一些解决方案。:)