open()在jquery mobile中不执行任何操作?
我不能使用target=\u blank,因为我的操作是动态生成的,例如:当用户单击链接时,我用.click(function(event)捕捉它,然后调用ajax api,然后在回调中我有url 现在的问题是: window.location=mylink;//有效-好! window.open(mylink);//不工作-不正常 为什么? 我需要打开一个新窗口,因为mylink是指向pdf文件的链接,并且在使用window.location时,可以正确查看pdf文件,但是,…没有浏览器的任何反向导航控件。这是一个移动webapp,我使用jquery mobileopen()在jquery mobile中不执行任何操作?,jquery,jquery-mobile,window.open,Jquery,Jquery Mobile,Window.open,我不能使用target=\u blank,因为我的操作是动态生成的,例如:当用户单击链接时,我用.click(function(event)捕捉它,然后调用ajax api,然后在回调中我有url 现在的问题是: window.location=mylink;//有效-好! window.open(mylink);//不工作-不正常 为什么? 我需要打开一个新窗口,因为mylink是指向pdf文件的链接,并且在使用window.location时,可以正确查看pdf文件,但是,…没有浏览器的任何
太糟糕了,在互联网上,许多其他人都有pdf查看器问题,但没有人解决它,所以我决定打开一个新窗口并在那里传递pdf链接。这样,我的父窗口将保持不变。否则,你必须终止当前会话并再次打开safari。如果你想在jQuery Mobile中打开对话框/弹出窗口,你必须o使用属性
data rel=“dialog”
,并且href
属性必须指向要加载的URL
<a href="yourpage.html" data-role="button" data-rel="dialog">Open dialog</a>
将target=“\u blank”添加到链接中。然后,在单击事件时调用此脚本。
它将在新窗口中打开您的pdf
$( "a" ).live( "click", function(event) {
var $this = $(this),
//get href, remove same-domain protocol and host
href = $this.attr( "href" ).replace( location.protocol + "//" + location.host, ""),
//if target attr is specified, it's external, and we mimic _blank... for now
target = $this.is( "[target]" ),
//if it still starts with a protocol, it's external, or could be :mailto, etc
external = target || /^(:?\w+:)/.test( href ) || $this.is( "[rel=external]" ),
target = $this.is( "[target]" );
if( href === '#' ){
//for links created purely for interaction - ignore
return false;
}
var testtarget = $this.attr( "target" );
if (testtarget == '_blank') {
alert('Leaving web app');
return true;
}
$activeClickedLink = $this.closest( ".ui-btn" ).addClass( $.mobile.activeBtnClass );
if( external || !$.mobile.ajaxLinksEnabled ){
//remove active link class if external
removeActiveLinkClass(true);
//deliberately redirect, in case click was triggered
if( target ){
window.open(href);
//return true;
}
else{
location.href = href;
}
}
else {
//use ajax
var transition = $this.data( "transition" ),
back = $this.data( "back" ),
changeHashOnSuccess = !$this.is( "[data-rel="+ $.mobile.nonHistorySelectors +"]" );
nextPageRole = $this.attr( "data-rel" );
//if it's a relative href, prefix href with base url
if( href.indexOf('/') && href.indexOf('#') !== 0 ){
href = getBaseURL() + href;
}
href.replace(/^#/,'');
changePage(href, transition, back, changeHashOnSuccess);
}
event.preventDefault();
});
可能是问题的答案,但这是问题的正确解决方案。thx-如果您已经阅读了我的问题,那么您已经了解我对通过链接()直接打开对话框/窗口不感兴趣,而是以编程方式在类似于window.open()的脚本中打开,但这不起作用,这就是我问这个问题的原因