简体   繁体   English

在经典ASP中的response.redirect之前运行Javascript函数

[英]Run Javascript Function before response.redirect in classic asp

I have some asp code where I need to execute some javascript function and then redirect the user to a new page. 我有一些ASP代码,我需要在其中执行一些javascript函数,然后将用户重定向到新页面。 when i do this ibn my code, I am response writing the javascript to the browser. 当我在我的代码中执行此操作时,我正在响应将JavaScript写入浏览器。 the issue that i am having is that the redirect occurs on ther server side, before the JS function finishes. 我遇到的问题是在JS功能完成之前,重定向发生在服务器端。 Is there a work around for this? 有没有解决的办法? Thanks 谢谢

Do the redirect in javascript. 在javascript中进行重定向。 At the end of your javascript function: 在javascript函数的末尾:

document.location.href = 'http://url-of-the-next-page';

I'm skeptical that there is a good reason to do it this way, but if you need to solve this problem I suggest you use JavaScript to do the redirection as well. 我怀疑这样做有充分的理由,但是如果您需要解决此问题,我建议您也使用JavaScript进行重定向。

That's the only way...ASP is going to process the entire script and can't wait for any client side script to finish. 这是唯一的方法... ASP将处理整个脚本,并且不能等待任何客户端脚本完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM