garyed Posted October 24, 2020 Share Posted October 24, 2020 When using javascript onchange with an alert function chrome freezes up. I've tried the same code in Firefox & it works fine so I'm wondering if it is a bug or I need to do something different in Chrome. This code couldn't be any simpler & it locks up my browser & freezes my mouse. I'm running Chrome in Ubuntu Linux 18.04. The same happens if I try a confirm function with onchange but both confirm & alert work as long as they are not used with the onchange function. <html> <head> </head> <body> <select name="testify" onchange="alert('something');"> <option value=1> one </option> <option value=2> two </option> </select> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/311640-is-this-a-bug-in-chrome-or-am-i-missing-something/ Share on other sites More sharing options...
requinix Posted October 24, 2020 Share Posted October 24, 2020 There's nothing unusual in there so I have to assume there's something more going on here than just the alert. Quote Link to comment https://forums.phpfreaks.com/topic/311640-is-this-a-bug-in-chrome-or-am-i-missing-something/#findComment-1582038 Share on other sites More sharing options...
garyed Posted October 25, 2020 Author Share Posted October 25, 2020 If anyone is using Chromium broswer I'd be curious if they tried that code & see what happened. That code that I posted is the whole html file & nothing else. I made that simple html file just to test the onchange & alert functions together to see why they wouldn't work on my website. In Firefox it works as expected but in Chrome it crashes my browser & freezes my mouse & I have go to the terminal to close the program down. I should have been more specific because it doesn't crash until you actually change from one option to the other. Then the alert pops up on the screen & that's when everything locks up. After spending most of the day on it I finally found a solution. There have evidently been some conflicts with Chrome & the alert & confirm javascript functions & the only thing that worked for me was to use the setTimeout function. After adding that, everything works in Chrome. It's possible it's just the particular Linux version of Chrome that I am using. This works now: <html> <head> </head> <body> <select name="testify" onchange="setTimeout(function(){ alert('something'); })"> <option value=1> one </option> <option value=2> two </option> </select> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/311640-is-this-a-bug-in-chrome-or-am-i-missing-something/#findComment-1582048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.