apache / apache/cordova-plugin-inappbrowser
Javascript execution backwards
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
# Bug Report
## Problem
Javascript execution backwards
### What is expected to happen?
Javascript lines of code are executed in order.
### What does actually happen?
We have been experiencing erratic behaviour when throwing __doPostBack().
Trying to go as simple as possible I wrote a JS function with 3 alerts. The alerts are displayed backwards.
Adding `settimeout` between the alerts make they appear in the right order.
## Information
Using Cordova PlugIn InAppBrowser 3.2.1 to load a webpage built in Asp.Net 4.5.2. >
### Command or Code
```lang-html
EXECUTION
```
Using unobstrusive JS with the same results:
```lang-html
Test
```
```lang-js
$(document).ready(function () {
$("#testButton").click(function () {
alert('1');
alert('2');
alert('3');
});
});
```
Adding 2 seconds timeouts displays the alerts in order:
```lang-js
$("#testButton").click(function () {
alert('1');
setTimeout(function () { alert('2'); }, 2000);
setTimeout(function(){ alert('3'); }, 4000);
});
```
But not if the timeouts are closer. The following code fails:
```lang-js
$("#testButton").click(function () {
alert('1');
setTimeout(function () { alert('2'); }, 1);
setTimeout(function(){ alert('3'); }, 2);
});
```
### Environment, Platform, Device
ios mobile devices
### Version information
Cordova 3.2.1
ApsNet 4.5.2
## Checklist
- [x] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Use the inline onclick and jQuery click-handler snippets as the starting reproduction, comparing immediate alerts with the 1–2 ms timeout examples on iOS. Confirm whether the behavior occurs specifically in the InAppBrowser context rather than the ASP.NET page; done means a minimal reproducible case and a verified fix or documented platform limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript, jquery
- Domain
- mobile-dev, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100