简体   繁体   English

为什么将JavaScript称为“ alert();” 功能为Apache Cordova开发时,Windows Phone中的应用程序崩溃了吗?

[英]Why does calling the JavaScript 'alert();' function crash the app in Windows Phone when developing for Apache Cordova?

I am currently working on a Apache Cordova project, and I am having issues calling the 'alert()' JavaScript function, and using the notification plugin. 我目前正在研究Apache Cordova项目,并且在调用'alert()'JavaScript函数并使用通知插件时遇到问题。 It works fine in my iOS and Android app, but it crashes my app when I run it on Windows Phone. 它可以在我的iOS和Android应用程序中正常运行,但是当我在Windows Phone上运行该应用程序时,该应用程序会崩溃。 Can someone tell me how I can fix this issue? 有人可以告诉我如何解决此问题吗? Thanks, ColtonW 谢谢,ColtonW

well, the alert should not be used in Android or iPhone too! 好吧,警报也不应在Android或iPhone中使用!

for example, suppose you use alert in android, open the app and use a timer to open the alert dialog box after 10 seconds, then within this 10 seconds, put your app. 例如,假设您在android中使用Alert,打开应用程序并使用计时器在10秒钟后打开警报对话框,然后在这10秒钟之内放置您的应用程序。 in background by pressing the hardware home key. 在后台按硬件主键。 Then when the alert fires, your application craches! 然后,当警报触发时,您的应用程序崩溃了!

so I wrote a 'showalert()' function in JavaScript to replace the alert function. 因此我在JavaScript中编写了一个“ showalert()”函数来替换警报功能。 inside the showalert function, I have an outer div, the size is the whole screen and with a transparent background, then inside this div, I have Another div located at the center of the outer div. 在showalert函数中,我有一个外部div,大小是整个屏幕并具有透明背景,然后在此div中,我有另一个div位于外部div的中心。 inside the inner div, I can put the alert message and I have a button to hide the outer div. 在内部div内,我可以放置警报消息,并且有一个按钮可以隐藏外部div。

remember to set the z-index of the outer div to a value larger then anything else in your html file. 切记将外部div的z-index设置为大于html文件中其他值的值。 eg 98. then, set the z-index of the inner div to 99. 例如98。然后,将内部div的z-index设置为99。

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

相关问题 Windows Phone 8上使用HTML / JavaScript / Apache Cordova的页面导航 - Page Navigation on Windows Phone 8 using HTML/JavaScript/Apache Cordova Cordova和Windows Phone,调用cordova.exec - Cordova and Windows Phone, calling cordova.exec 为什么onPress中的Button警报会导致博览会应用程序崩溃? - Why does an alert in onPress of a Button crash the expo app? 使用Javascript开发Windows Phone应用 - Developing windows phone Apps using Javascript Visual Studio 2015 RC Cordova应用程序(Windows Phone Universal,“警报”未定义) - Visual Studio 2015 RC Cordova App (Windows Phone Universal, “alert” undefined) javascript Apache Cordova警报和document.write - javascript apache cordova alert and document.write 在这个 Javascript function 为什么 alert(multi) 警告值 '3' - In this Javascript function why does alert(multi) alert the value '3' 在C#Windows Phone 7.5应用程序中调用javascript代码 - calling javascript code in C# Windows Phone 7.5 app 从C#Windows Phone应用程序调用Javascript-这是一个好方法吗? - Calling Javascript from C# Windows Phone App - Is it a good method? 用于Apache Cordova的JavaScript代码在模拟器Ripple上运行,但不在Live Windows Phone设备中运行(L 535) - javascript code for apache Cordova working on simulator Ripple but not in Live windows phone Device (L 535)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM