JavaScript确认窗口在iPhone的Safari上始终返回false

编程入门 行业动态 更新时间:2024-10-09 03:27:06
本文介绍了JavaScript确认窗口在iPhone的Safari上始终返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Knockout.JS来驱动表单,并且有一个按钮,当按下该按钮时会显示一个确认窗口.仅在适用于iPhone的Safari中,它始终返回false.它可以在iPhone上与Chrome一起使用,在iPad和笔记本电脑上也可以在所有浏览器(包括Safari)上使用.也没有错误.

I'm using Knockout.JS to power a form and I have a button that when pressed displays a confirmation window. Only on Safari for iPhone it always returns false. It works with Chrome on my iPhone, and on my iPad and laptop it works on all browsers(including Safari). There are no errors either.

self.submitPayment = function(){ var errors2 = ko.validation.group(secondValidationGroup); if (errors2().length == 0) { if(confirm_reservation() == true){ finalizePayment(); //calls function which displays a new div } else{ alert('False was returned'); //displays before I even make a selection } } else{ errors2.showAllMessages(); } } //used to confirm submission for submitPayment function confirm_reservation(){ var conf = confirm('Click OK to submit your payment'); return conf; }

在进行选择之前,我会收到返回了错误"的警报.因此,基本上,它甚至不能让我在返回值之前进行选择.

Before I even make a selection, I get the 'False was returned' alert. So basically it's not even letting me make a selection before it returns the value.

编辑-现在可以使用了,我想我可能遇到了错误

我清除了手机上的cookie/缓存,然后将其重新启动,然后它可以正常工作.

I cleared my cookies/cache on my phone and restarted it and then it proceeded to work properly.

推荐答案

我认为由于asycnhronus的问题,您的"confirm_reservation"方法不会等待确认结果,而是直接返回false.和你一起.

I think the problem due the asycnhronus things, your "confirm_reservation" method doesnot wait the confirm result, and return false directly.. Can you try below confirm block changing with yours.

confirm('Click OK to submit your payment', function(result) { if(result) { finalizePayment(); } else { alert('False was returned'); //displays before I even make a selection } });

更多推荐

JavaScript确认窗口在iPhone的Safari上始终返回false

本文发布于:2023-11-27 21:35:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   JavaScript   iPhone   false   Safari

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!