[英]how to pass javascript function inside res.send
//defined in xyz.js
function getRedirectPage(pageName) {
setTimeout(function(){
window.location = "/"+pageName;
},3000);
}
//server code
app.get('',function(req,res){
res.send("<script>getRedirectPage('page1')</script>")
});
you should add href method and change it to redirect, see the code below您应该添加 href 方法并将其更改为重定向,请参见下面的代码
function getRedirectPage(pageName) { setTimeout(function () { window.location.href = "/" + pageName; }, 3000); } app.get('',function(req,res){ res.redirect("<script>getRedirectPage('page1')</script>") });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.