Ios iPhone全屏放大弹出窗口
我在一个网站上使用神奇的放大弹出脚本来显示图片库 该网站也是一款能够在iPad和iPhone上全屏观看的苹果移动web应用程序 我正在使用Stay Standalone脚本()来防止在页面之间导航时被转储回Mobile Safari:Ios iPhone全屏放大弹出窗口,ios,iphone,popup,magnific-popup,Ios,Iphone,Popup,Magnific Popup,我在一个网站上使用神奇的放大弹出脚本来显示图片库 该网站也是一款能够在iPad和iPhone上全屏观看的苹果移动web应用程序 我正在使用Stay Standalone脚本()来防止在页面之间导航时被转储回Mobile Safari: (function(document,navigator,standalone) { // prevents links from apps from oppening in mobile safari // this javascript mus
(function(document,navigator,standalone) {
// prevents links from apps from oppening in mobile safari
// this javascript must be the first script in your <head>
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a|html)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
curnode=curnode.parentNode;
}
// Condidions to do this only on links to your own app
// if you want all links, use if('href' in curnode) instead.
if(
'href' in curnode && // is a link
(chref=curnode.href).replace(location.href,'').indexOf('#') && // is not an anchor
( !(/^[a-z\+\.\-]+:/i).test(chref) || // either does not have a proper scheme (relative links)
chref.indexOf(location.protocol+'//'+location.host)===0 ) // or is in the same protocol and domain
) {
e.preventDefault();
location.href = curnode.href;
}
},false);
}
})(document,window.navigator,'standalone');
(功能(文档、导航器、独立){
//防止来自应用程序的链接在mobile safari中出现
//此javascript必须是您的应用程序中的第一个脚本
if((导航器中的独立)和&navigator[独立]){
var curnode,location=document.location,stop=/^(a | html)$/i;
document.addEventListener('click',函数(e){
curnode=e.target;
while(!(停止).test(curnode.nodeName)){
curnode=curnode.parentNode;
}
//有条件仅在指向您自己应用程序的链接上执行此操作
//如果需要所有链接,请改用if('href'在curnode中)。
如果(
curnode&&//中的“href”是一个链接
(chref=curnode.href).replace(location.href',).indexOf('#')&&&//不是锚定
(!(/^[a-z\+\.\-]+:/i).test(chref)\\\//或者没有正确的方案(相对链接)
chref.indexOf(location.protocol+'/'+location.host)==0)//或位于同一协议和域中
) {
e、 预防默认值();
location.href=curnode.href;
}
},假);
}
})(文档,window.navigator,'standalone');
此脚本防止在iOS上以全屏模式启动放大弹出窗口。我的放大弹出式初始化脚本如下:
jQuery(document).ready(function($) {
$('.lightview').magnificPopup({
type: 'image',
removalDelay: 500,
gallery:{
enabled:true,
},
image: {
verticalFit: true,
titleSrc: function(item) {
return '<strong>' + item.el.attr('title') + '</strong>' + ' <br /><span class="lightbox-caption">' + item.el.attr('data-caption') + '</span>';
},
markup: '<div class="mfp-figure">'+
'<div class="mfp-close"></div>'+
'<div class="mfp-img"></div>'+
'<div class="mfp-title-holder">'+
'<div class="mfp-title"></div>'+
'</div>'+
'<div class="mfp-bottom-bar">'+
'<div class="mfp-counter"></div>'+
'</div>'+
'</div>'
},
callbacks: {
beforeOpen: function() {
this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
this.st.mainClass = this.st.el.attr('data-effect');
}
},
cursor: 'mfp-zoom-out-cur',
closeOnContentClick: false,
midClick: true
});
});
jQuery(文档).ready(函数($){
$('.lightview')。放大弹出窗口({
键入:“图像”,
移动延迟:500,
画廊:{
启用:对,
},
图片:{
垂直拟合:正确,
标题RC:功能(项目){
返回“”+item.el.attr('title')+”'+'
'+item.el.attr('data-caption')+”;
},
标记:“”+
''+
''+
''+
''+
''+
''+
''+
''+
''
},
回调:{
beforeOpen:函数(){
this.st.image.markup=this.st.image.markup.replace('mfp-figure','mfp-figure-mfp-with-anim');
this.st.mainClass=this.st.el.attr(“数据效应”);
}
},
光标:“mfp缩小电流”,
closeOnContentClick:false,
点击中键:正确
});
});
我怎样才能停止保持独立,不干扰放大弹出窗口
我有一个自动打开的放大弹出窗口在我的网站上的其他地方,这是不受影响的,它似乎只是弹出窗口,是通过点击一个链接调用
提前感谢您的帮助 我通过在Stay Standalone脚本中添加一个针对我的弹出链接数据属性的条件,解决了这个问题。我的最终版本:
(function (a, b, c) {
if (c in b && b[c]) {
var d, e = a.location,
f = /^(a|html)$/i;
a.addEventListener("click", function (a) {
d = a.target;
while (!f.test(d.nodeName)) {
d = d.parentNode
}
if ("href" in d && (chref = d.href).replace(e.href, "").indexOf("#")
&& !d.attributes.getNamedItem("data-effect") // <- FIX IS HERE!
&& (!/^[a-z\+\.\-]+:/i.test(chref) || chref.indexOf(e.protocol + "//" + e.host) === 0)) {
a.preventDefault();
e.href = d.href
}
}, false)
}
})(document, window.navigator, "standalone");
(功能(a、b、c){
if(b中的c和b[c]){
变量d,e=a.位置,
f=/^(a | html)$/i;
a、 addEventListener(“单击”),函数(a){
d=a.目标;
而(!f.test(d.nodeName)){
d=d.parentNode
}
如果d&&(chref=d.href)中的“href”,则替换为(e.href,”).indexOf(“#”)
&&!d.attributes.getNamedItem(“数据效果”)//