如何避免页面刷新,直到用户单击按钮? [英] How to avoid page refresh until User click the button?

查看:91
本文介绍了如何避免页面刷新,直到用户单击按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请中, Captcha 12分钟后 。在这里没有应用这样的验证以避免页面刷新,因此,当Captcha进入屏幕并且用户刷新页面然后验证码消失从屏幕上没有将Captcha细节填入文本框。现在我希望当验证码出现在屏幕上时,用户无法刷新页面,直到他提交验证码。



Hereis我的 javascript for captcha



 function ShowNewPage(){
var callbackFunctionArray = new Array(CloseCaptchaPopUp);
modalWin.ShowURL(' Captcha.aspx' 225 290 ' 请输入图像中显示的字符以继续' null ,callbackFunctionArray);
}





Aspx页面代码



 <   div     id   =  Popup_content >  
< div class = box1 >
< div class = popupheadrow >
< p class = title >
请输入以下文字:
< / p >
< / div >
< div class = bodyrow align = center >
< div class = row style = min-height:18px >
< asp:标签 ID = lblMessage runat = server style = 颜色:绿色; font-size:0.8em; 文本 = > < / asp:标签 >
< / div >
< div class = row >
< asp:Image ID = Image1 runat = server ImageUrl = CaptchaImage.aspx 样式 = width:255px / >
< / div >
< div class = row >
< asp:TextBox ID = txtimgcode runat = server CssClass = fields TabIndex = 1 MaxLength = 10

自动完成 = false > < / asp:TextBox >
< / div >
< div class = row > ;
< asp:按钮 ID = CaptchaSubmit CssC lass = 提交 runat = server OnClick = CaptchaSubmit_Click

< span class =code-attribute>
< span class =code-attribute> 文本 = 提交 高度 = 26px / >
< asp:按钮 style = < span class =code-keyword> display:none id = btnHidden runat = server OnClick = btnHidden_​​Onclick / >
< span class =code-keyword>< / div >
< / div >
< / div >
< script type = text / javascript >
setInterval(function(){btnHidden.click() ; },60000);
< / script >
< script 类型 = text / javascript language = javascript >
函数CloseCaptchaModalPopup(){
window.parent.modalWin.CallCallingWindowFunction(0, '信息保存得很快');
}
< / script >
< / div >







建议我解决一下如何避免页面刷新直到用户提交验证码。

解决方案

您可以验证按键事件以验证捕获文本框。





禁用F5

[ ^ ]





参考上面的链接。在F5的Keypress事件中,如果验证码文本框没有值,则返回false。



如果这对您有用,请告诉我。



问候,

Maheswaran.S


如何在captcha文本框焦点上禁用f5?



F5禁用文档元素重点

[ ^ ]



试试这个。它对你有用。只有当您的页面中出现验证码时,F5才会被禁用。





问候,

Maheswaran.S

In my application a Captcha is coming at after every 12 minutes. In this there is no such validation applied to avoid page refresh, so because of this when Captcha come on the screen and user refresh the page and then captcha disappear from the screen without filling the Captcha details into the textbox. Now i want when the captcha come on the screen, User Can't be able to refresh the page until he submitted the captcha.

Hereis my javascript for captcha

function ShowNewPage() {
    var callbackFunctionArray = new Array(CloseCaptchaPopUp);
    modalWin.ShowURL('Captcha.aspx', 225, 290, 'Please enter characters dislayed in image to proceed', null, callbackFunctionArray);
}



Aspx Page code

<div id="Popup_content">
        <div class="box1">
            <div class="popupheadrow">
                <p class="title">
                    Please enter text below:
                </p>
            </div>
            <div class="bodyrow" align="center">
                <div class="row" style="min-height: 18px">
                    <asp:Label ID="lblMessage" runat="server"  style="color:Green; font-size: 0.8em;" Text=" "></asp:Label>
                </div>
                <div class="row">
                    <asp:Image ID="Image1" runat="server" ImageUrl="CaptchaImage.aspx" Style="width: 255px" />
                </div>
                <div class="row">
                    <asp:TextBox ID="txtimgcode" runat="server" CssClass="fields" TabIndex="1" MaxLength="10"

                        AutoComplete="false"></asp:TextBox>
                </div>
                <div class="row">
                    <asp:Button ID="CaptchaSubmit" CssClass="submit" runat="server" OnClick="CaptchaSubmit_Click"

                        Text="Submit" Height="26px" />
                         <asp:Button style="display:none" id="btnHidden" runat="server" OnClick="btnHidden_Onclick" />
                </div>
            </div>
        </div>
        <script type="text/javascript">
            setInterval(function () { btnHidden.click(); }, 60000);
</script>
        <script type="text/javascript" language="javascript">
            function CloseCaptchaModalPopup() {
                window.parent.modalWin.CallCallingWindowFunction(0, 'Information Saved Scucessfully');
            }
        </script>
    </div>




Suggest me some solution How could i avoid Page refresh until user submitted the captcha.

解决方案

You can validate the key press event to validate catch text box.


Disable F5
[^]


refer the above link. In the Keypress event of F5, if the captcha text box doesn't have the value then return false.

Let me know if this works for you.

Regards,
Maheswaran.S


How about making the f5 disable on captcha textbox focus ?

F5 Disable in document element focus
[^]

Try this . It will work for u. F5 will be disabled only if captcha appears in your page.


Regards,
Maheswaran.S


这篇关于如何避免页面刷新,直到用户单击按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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