防止刷新asp.net中的页面 [英] prevent to refresh page in asp.net

查看:61
本文介绍了防止刷新asp.net中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击浏览器刷新按钮或[f5]键时,我希望该页面不会重新加载(刷新)
只是那个时候,没有,当按下任何按钮时,我只有在按下浏览器按钮(f5)上的刷新时才能执行此操作.

when user click on browser refresh button or(f5) key ,i want to that page will not go for reload (refresh)
only that time, no when press any button, i can want to this action any button only when press refresh on browser button(f5).

推荐答案

问题尚不清楚.如果我正确理解了您的问题,则无法阻止页面刷新.它是浏览器的功能,您无法通过页面中的代码对其进行控制.
Question is not clear. If I understand your question correctly, you cannot prevent a page refresh. It is a functionality of the browser and you cannot control it through code in your page.


刷新"页面时,总是会发生页面加载.这就是刷新"的本质.除此之外,您的问题无法准确回答,因为这里没有人理解.
When you "refresh" a page, a page-load is always going to happen. That''s the nature of a "refresh". Beyond that, your question is impossible to answer with any accuracy because nobody here understands it.


1.当用户使用Java脚本(使用F5按钮的键代码)按下F5时,可以避免刷新页面.
1. you can avoid refreshing page when user press the F5 using Java Script(Using Key Code of the F5 button).
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler() {
    switch (event.keyCode) {
        case 116 : // ''F5''
            event.returnValue = false;
            event.keyCode = 0;
            window.status = "We have disabled F5";
            break;
    }
}


2.当用户单击鼠标右键并通过Java脚本选择重新加载"选项时,可以避免刷新页面(我们可以在JS中找到鼠标按钮)


2. you can avoid refreshing page when user click the right mouse button and selects the Reload option by Java script(We can find the mouse button in JS)Restrict RIGHT CLICK.
3. To avoid the browser refresh(Need to open the page in pop-up).

These are not solutions. better tell me reason to avoid refresh. may You have a design flaw with your page.

Thanks
Karthik P


这篇关于防止刷新asp.net中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆