javascript - standalone web app link script - stop it from appending links which have a specific class? -
this script prevents links opening in mobile safari. when web app in app mode on ios (home screen bookmark).
if(("standalone" in window.navigator) && window.navigator.standalone){ // if want prevent remote links in standalone web apps opening mobile safari, change 'remotes' true var noddy, remotes = false; document.addeventlistener('click', function(event) { noddy = event.target; // bubble until hit link or top html element. warning: body element not compulsory better stop on html while(noddy.nodename !== "a" && noddy.nodename !== "html") { noddy = noddy.parentnode; } if('href' in noddy && noddy.href.indexof('http') !== -1 && (noddy.href.indexof(document.location.host) !== -1 || remotes)) { event.preventdefault(); document.location.href = noddy.href; } },false); }
my question how script above ignore links class?
so example i've a.lightbox
- , link opens , image in lightbox using www.photoswipe.com jquery plugin.
but when use script kills lightbox launch , opens image on own. if script above, photoswipe lightbox works fine.
has got suggestions or modifiy script ignore these links a.lightbox
thanks josh
if you're using jquery should able add && !$(noddy).hasclass('lightbox')
if test.
Comments
Post a Comment