简体   繁体   中英

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. It works fine in my iOS and Android app, but it crashes my app when I run it on Windows Phone. Can someone tell me how I can fix this issue? Thanks, ColtonW

well, the alert should not be used in Android or iPhone too!

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. 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. 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. inside the inner div, I can put the alert message and I have a button to hide the outer div.

remember to set the z-index of the outer div to a value larger then anything else in your html file. eg 98. then, set the z-index of the inner div to 99.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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