Window.open () does not work in the Safari mobile web application added to the main screen

Here is all the code I tried:

select:function(event, ui) { window.open(ui.item.value, "_blank"); } select:function(event, ui) { window.location.href = ui.item.value; } 

When the screen simply refreshes in web application mode, it does not go to the location. At Mobile Safari, it works as intended.

Is this a limitation for web apps on the iPhone? Is there any way around this?

Here is the complete code:

 <script> $(document).ready(function() { var cct = $('input[name=csrf_token]').val(); var searchInput = $('input[name=search]'); function loadEventsData(onSuccess){ $.ajax({ type: 'POST', url: '<?php echo site_url('ajax_frontend/getEventsSearch'); ?>', dataType: 'json', success: onSuccess, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); } }); } function initializeEventsAutocomplete(data){ searchInput.addClass('loaded').autocomplete({ source:data, appendTo: '.search_autocomplete', minLength:2, delay:0, selectFirst:false, open: function(event, ui) { $('ul.events').hide(); $('.ui-autocomplete').removeAttr('style'); $('.icon-search').hide(); $('.icon-close').show(); }, close: function(event, ui) { val = searchInput.val(); searchInput.autocomplete("search", val); searchInput.focus(); return false; }, select:function(event, ui) { window.location.href = ui.item.value; return false; } }); } $('form').submit(function(e) { e.preventDefault(); searchInput.blur(); }); searchInput.keyup(function(){ if($(this).is(".loaded")) return; loadEventsData(initializeEventsAutocomplete); }); $('.icon-close').click(function(e) { e.preventDefault(); $(this).hide(); $('.icon-search').show(); searchInput.autocomplete('close'); $('ul.events').show(); searchInput.val(''); }); }); </script> 

And here is the JSON (some of them):

 [{"value":"http:\/\/events.dev\/index.php\/event\/canada-day","label":"Canada Day"},{"value":"http:\/\/events.dev\/index.php\/event\/triathlon-festival","label":"Triathlon Festival"}] 
+7
source share
2 answers

I get it. I use the following code to prevent links from opening in a web application in Safari:

https://gist.github.com/1042026

This caused some unwanted side effects. To fix this, I added:

event.stopPropagation ();

into my selection:function scope, and it works as it should.

+1
source

Programmatically (Javascript) opens a link in Mobile Safari. Ideally, if you cannot use the standard html link, but you should use Javascript:

 var a = document.createElement("a"); a.setAttribute('href', facebook); a.setAttribute('target', '_blank'); a.click(); 
+1
source

All Articles