开发者

Trouble with creating web pages

开发者 https://www.devze.com 2023-04-10 12:58 出处:网络
I\'m having trouble with creating a web page with following features: When users visit my page, their address bar will display ONLY URLs having no accompanied ID such as http://127.0.0.1/client

I'm having trouble with creating a web page with following features:

  • When users visit my page, their address bar will display ONLY URLs having no accompanied ID such as http://127.0.0.1/client

  • Whenever they REFRESH the page, real requested URLs will be attached with IDs. For example: http://127.0.0.1/client?id=3

Previously, I tried to use hidden input tags, bu开发者_如何转开发t it's fruitless. Any idea?

My mark up is below

<html>
<head>
    <meta http-equiv='refresh' content='1,url=/client'>
</head>
<body onload="JavaScript:setTimeout('location.reload(true);',0);">
    <input type="hidden" name="id" value="3" />
</body>
</html>


You can hijack page refresh with something that POSTs to your page.


You could use pushState to change the url on load like:

function updateURL (){
    window.history.pushState(null, null, "?id=3")
}

window.onload=updateURL;

You could also accomplish something similar using location.hash as pushState is not supported on some old browsers.

0

精彩评论

暂无评论...
验证码 换一张
取 消