简体   繁体   English

当用户想要重新加载页面时,自定义URL

[英]customize url when user wants to reload the page

I am working in a node js project. 我正在节点js项目中工作。 going page to page using redirect from server.js file. 使用从server.js文件中重定向的页面到页面。 I have manually customized url using window.history.pushState("","","custom.url.testing/taslim"); 我已经使用window.history.pushState("","","custom.url.testing/taslim");手动定制了URL window.history.pushState("","","custom.url.testing/taslim"); from html page script. 从html页面脚本。

Now the problem is when ever user reload the page it shows cannnot get /custom.url.testing/taslim . 现在的问题是,当用户重新加载页面时,它显示cannnot get /custom.url.testing/taslim

how can I customize url before reload operation after pressing reload button in browser? 在浏览器中按下重新加载按钮后,如何在重新加载操作之前自定义url?

Then use 然后使用

    $(document).ready(function(){

    });

for that url. 该网址。

You need to update your node.js server to handle all your custom urls, and return the same as the route you want your user to load. 您需要更新node.js服务器以处理所有自定义URL,并返回与您希望用户加载的路由相同的路由。

This might mean that you set up a wildcard rule so that anything with /custom.url.testing/* will load the same code. 这可能意味着您设置了通配符规则,以便具有/custom.url.testing/*都将加载相同的代码。

this would probably look like 这可能看起来像

app.get("/custom.url.testing/*", function(req, res, next){
  // same as whatewer your default route  is
  next();
});

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

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