how to prevent iOS safari alert when trying to open non-installed native app?

Here is a solution that works for me: var timeout; function preventPopup() { clearTimeout(timeout); timeout = null; window.removeEventListener(‘pagehide’, preventPopup); } function openApp() { $(‘<iframe />’) .attr(‘src’, appurl) .attr(‘style’, ‘display:none;’) .appendTo(‘body’); timeout = setTimeout(function() { document.location = appstore; }, 500); window.addEventListener(‘pagehide’, preventPopup); }

Force link to open in mobile safari from a web app with javascript

This is possible. Tested with iOS5 stand-alone web app: HTML: <div id=”foz” data-href=”http://www.google.fi”>Google</div> JavaScript: document.getElementById(“foz”).addEventListener(“click”, function(evt) { var a = document.createElement(‘a’); a.setAttribute(“href”, this.getAttribute(“data-href”)); a.setAttribute(“target”, “_blank”); var dispatch = document.createEvent(“HTMLEvents”); dispatch.initEvent(“click”, true, true); a.dispatchEvent(dispatch); }, false); Can be tested here: http://www.hakoniemi.net/labs/linkkitesti.html

Preventing default context menu on longpress / longclick in mobile Safari (iPad / iPhone)

Thanks to JDandChips for pointing me to the solution. It works perfectly in combination with the longclick plugin. For documentation sake I’ll post my own answer to show what I did. HTML: <script type=”text/javascript” src=”https://raw.github.com/pisi/Longclick/master/jquery.longclick-min.js”></script> <p><a href=”http://www.google.com/”>Longclick me!</a></p> The Javascript already was OK: function longClickHandler(e){ e.preventDefault(); $(“body”).append(“<p>You longclicked. Nice!</p>”); } $(“p a”).longclick(250, longClickHandler); The fix … Read more

Difference between onbeforeunload and onunload

onunload is responsible for executing an instruction when the page is closed. It also causes issue with IE and AJAX. onbeforeunload is more efficient because it does not run in competition with the actual closing of the window and is triggered before onunload I know Opera used to not acknowledge onbeforeunload – not sure if … Read more

iPhone “Bookmark to Homescreen” removes cookies and session?

A really simple approach could be to use a unique token in your Bookmark-URL which can serve you as a unique device identifier. Example: http://myWebApp.com/?token=randomId29238/1 The token can be generated at the server side at opening time of the application in Mobile Safari and before the user is prompted with the “Add to Home Screen” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)