Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//- partials/_safari-web-app.pug:jeff
//-
//- https://gist.github.com/kylebarrow/1042026
//- http://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window
script().
'use strict';
var script = document.createElement('script');
script.innerHTML = `(function(standalone) {
if(!standalone) {
return;
}
document.addEventListener('click', function(evt) {
var element = evt.target,
href = '';
while(!/^(a|html)$/i.test(element.nodeName)) {
element = element.parentNode;
}
if(element.getAttribute) {
href = element.getAttribute('href');
if('' !== href && '#' !== href && null !== href && (!element.protocol || element.protocol !== 'tel:')) {
evt.preventDefault();
window.location = element.href;
}
}
}, false);
}(window.navigator.standalone));`
document.head.appendChild(script);
//- HTML5 doctype
doctype html
html(lang='en')
head
append meta
meta(name='apple-mobile-web-app-capable', content='yes')
meta(name='apple-mobile-web-app-status-bar-style', content='black-translucent')
meta(name='apple-mobile-web-app-title', content='Naughty Girl | naughty.im')
include partials/_safari-web-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.