简体   繁体   English

用户进入特定网页后如何禁用刷新按钮?

[英]How to disable refresh button once user goes on a particular web page?

I have to create a web page for a online quiz which will display same questions in different sequence for each user. 我必须为在线测验创建一个网页,该网页将为每个用户以不同的顺序显示相同的问题。 Now, I have written code which takes questions randomly every time when user visit that page. 现在,我编写了代码,每次用户访问该页面时都会随机询问问题。 User goes to that page by login id and password. 用户通过登录ID和密码转到该页面。 I have used random function in query which gives questions in different order for each user. 我在查询中使用了随机函数,该函数为每个用户以不同的顺序给出问题。 But now problem is when i refresh that page question order changes for the same user. 但是现在的问题是,当我刷新该页面时,同一用户的问题顺序会发生变化。 So i wants to disable refresh button. 所以我想禁用刷新按钮。 Can you please tell me how to disable it? 你能告诉我如何禁用它吗? or is there any other way? 或还有其他方法吗?

It's impossible to disable refresh button. 禁用刷新按钮是不可能的。

You can try to save questions order in users session and then use it. 您可以尝试在用户会话中保存问题顺序,然后再使用它。

You can't disable the button. 您不能禁用该按钮。 You shouldn't be messing with the user's browser. 您不应该弄乱用户的浏览器。

What you can do however, is to show a dialog asking the user if they want to leave the page. 但是,您可以做的是显示一个对话框,询问用户是否要离开页面。

<body onbeforeunload="return 'Are you sure you want to leave the page?';">

只需每个会话或登录一次而不是在每个请求上生成并存储问题顺序一次。

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

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