Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Safari browser, change # hash URL and then Javascript alert message box stop working

Tags:

I run a web page in iPhone Safari. The page has a button. on clicking it, will show an alert message box. This is OK. Then, I change or add # hash URL by typing in the address bar, then, alert message box stop working. I click the button, and nothing happens. No javascript error but no alert message box.

video recording of the issue

Is this iOS Safari known issue?

Please share your thoughts and the solution you have come up with. Many Thanks!

$(".button").click(function () {    alert('Hello');  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>  <input class="button" type="button" value="alert" />

Note:

  • This is not quite due to my code. I have also tested at Here
  • I have tested in the most recent iOS versions.
  • Javascript itself is working
  • Not JQuery issue, plain JS code also does not work
  • An alert box is working in iPhone Chrome or other browsers
like image 645
Pyae Phyo Aung Avatar asked Jan 19 '18 09:01

Pyae Phyo Aung


People also ask

Why did iOS change Safari?

Apple says two of its goals with the new Safari in iOS 15 were making “controls easier to reach with one hand” and putting “content front and center.” There's no doubt it will take some getting used to as there's some muscle memory to rewrite.

How do I change the default browser on my iPhone?

How to Change Default Browser on iPhone 1 Go to Settings and scroll until you find the third-party app. 2 Tap the app, then tap Default Browser App. 3 Select a web browser to set it as the default. A checkmark should appear next to the browser to confirm it's the default. See More....

How do I change Safari settings on my iPhone or iPad?

Open your iPhone or iPad's Settings . It's the gear icon typically found on the home screen. Scroll down and tap Safari. It's in the 5th group of settings. Scroll down to the "SETTINGS FOR WEBSITES" SECTION. It's toward the bottom of the menu.

How do I change the default mail app in Safari?

Instead, go to "Safari" in the Settings app, choose "Default Mail App," then pick "Safari." When Safari is the default on your system, this menu item will not appear in Safari's settings — only in the settings for third-party browsers. This is, no doubt, Apple's way of silently discouraging you from moving away from its own app.

How to change Reader Mode settings on iOS 15 Safari?

Launch the redesigned iOS 15 Safari app and visit a website. Tap the more icon (three dots inside a circle). Tap Reader to see the webpage in distraction-free reader mode. Follow the same steps to exit it. Tap the more icon again and select Reader Mode Settings for further customization.


1 Answers

Could be related to Alert, confirm, and prompt not working after using History API on Safari, iOS and https://forums.developer.apple.com/thread/65054

It seems that alert() becomes undefined. A suggested workaround is to use custom popups instead.

like image 97
Tzach Ovadia Avatar answered Sep 17 '22 18:09

Tzach Ovadia