![Avatar of SethSanders](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
SethSanders
asked on
iOS 7 onchange event is broken in iPad 3+Mini // Need work around
Please test this only on iPad running ios 7
It appears that iOS 7 doesn't support alert() and confirm() for onchange events on iPad. Strange thing is that it works on iPhone 4s running ios 7.0 and in desktop browser but not on ipad 3 or ipad mini running ios 7.0. It fires the dialog and when clicked it darkens the button (as if it was clicked) and then the browser freezes. Happens in both Safari and chrome running on iOS 7 iPad and iPad mini.
Any pointers would be greatly appreciated. Already tried onblur and onkeypress with no success :-/
Issue can be seen here (make sure to test it on iPad running iOS 7): http://jsfiddle.net/sethsanders/MvSxm/
It appears that iOS 7 doesn't support alert() and confirm() for onchange events on iPad. Strange thing is that it works on iPhone 4s running ios 7.0 and in desktop browser but not on ipad 3 or ipad mini running ios 7.0. It fires the dialog and when clicked it darkens the button (as if it was clicked) and then the browser freezes. Happens in both Safari and chrome running on iOS 7 iPad and iPad mini.
Any pointers would be greatly appreciated. Already tried onblur and onkeypress with no success :-/
Options
<select id="iCard" onchange="alert('It worked.')">
<option value="0" selected="selected">(none)</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
Issue can be seen here (make sure to test it on iPad running iOS 7): http://jsfiddle.net/sethsanders/MvSxm/
![Avatar of Kim Walker](https://filedb.experts-exchange.com/files/public/2013/11/18/a0c622b7-b7fe-40b8-8b2f-0c6fe09d4982.png)
The standards compliant method would be to tell it what script engine to use and end with a semi-colon. Maybe the iPad is picky.
Options
<select id="iCard" onchange="javascript: alert('It worked.');">
<option value="0" selected="selected">(none)</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
![Avatar of Michel Plungjan](https://filedb.experts-exchange.com/files/public/2014/4/8/e546cd26-9765-49a6-8355-ac1156395953.jpeg)
No way. The semicolon is only EVER needed in event handlers to SEPARATE statements
![Avatar of Kim Walker](https://filedb.experts-exchange.com/files/public/2013/11/18/a0c622b7-b7fe-40b8-8b2f-0c6fe09d4982.png)
One more thing that might help a picky browser would be to return true at the end.
Options
<select id="iCard" onchange="javascript: alert('It worked.');return true;">
<option value="0" selected="selected">(none)</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
![Avatar of Michel Plungjan](https://filedb.experts-exchange.com/files/public/2014/4/8/e546cd26-9765-49a6-8355-ac1156395953.jpeg)
@xmediaman Are you guessing here?
1) javascript: pseudo protocol/label is ONLY EVER needed in IE if there is a VBScript at the top of the page
2) return true is only needed in a very few handlers, the only ones I can think of is onmouseover/out when you change the status line (no longer allowed in most browsers) and in any handler that returns EITHER true OR false such as a submit handler with a validation.
1) javascript: pseudo protocol/label is ONLY EVER needed in IE if there is a VBScript at the top of the page
2) return true is only needed in a very few handlers, the only ones I can think of is onmouseover/out when you change the status line (no longer allowed in most browsers) and in any handler that returns EITHER true OR false such as a submit handler with a validation.
![Avatar of Kim Walker](https://filedb.experts-exchange.com/files/public/2013/11/18/a0c622b7-b7fe-40b8-8b2f-0c6fe09d4982.png)
Absolutely. Obviously iOS7 on the iPad 3 isn't behaving normally so I'm making suggestions that might work. I don't have anything to test on. After all, who'd of ever thought that adding and empty onclick attribute on a label tag would overcome previous iOS issues. But it works.
![Avatar of Michel Plungjan](https://filedb.experts-exchange.com/files/public/2014/4/8/e546cd26-9765-49a6-8355-ac1156395953.jpeg)
Perhaps it is because your fiddle is running onload, which creates this code where the function is not in the window scope
Please try this version where I load the function in the head instead
JSFiddle
I will test on iPad 3 iOS7 in a few hours - it works on my 4S iOs7
<script type='text/javascript'>
window.onload=function(){
function SetCard(cVal, cTxt) {
alert('SetCard called successfully.')
}
</script>
Please try this version where I load the function in the head instead
JSFiddle
I will test on iPad 3 iOS7 in a few hours - it works on my 4S iOs7
![Avatar of SethSanders](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
I tested all of the above possible solutions and none of them have worked so far :-/
@mplungjan: My original fiddle code ran no problem on my 4s running iOS7 as well. This is really baffling.
@mplungjan: My original fiddle code ran no problem on my 4s running iOS7 as well. This is really baffling.
![Avatar of Michel Plungjan](https://filedb.experts-exchange.com/files/public/2014/4/8/e546cd26-9765-49a6-8355-ac1156395953.jpeg)
I can confirm this case with iPad 3 iOs7
I raised bug #15067555 with apple.
I raised bug #15067555 with apple.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
![Avatar of SethSanders](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Thanks mplungjan! That works!
![Avatar of Michel Plungjan](https://filedb.experts-exchange.com/files/public/2014/4/8/e546cd26-9765-49a6-8355-ac1156395953.jpeg)
Thanks a LOT Apple!
Apple Developer Relations22-Oct-2013 01:43 AM
Engineering has determined that your bug report is a duplicate of another issue and will be closed.
---
but I cannot see the closed issue
Apple Developer Relations22-Oct-2013 01:43 AM
Engineering has determined that your bug report is a duplicate of another issue and will be closed.
---
but I cannot see the closed issue
Open in new window
instead?