JavaScript/JQuery在Cordova中为iframe启用backbutton行为
我正在科尔多瓦开发一个Webview应用程序。此webview应用程序具有iframe,我将在其中显示我网站的内容 但是单击backbutton会重定向到上一页,而不是返回iframe页面JavaScript/JQuery在Cordova中为iframe启用backbutton行为,javascript,android,jquery,cordova,iframe,Javascript,Android,Jquery,Cordova,Iframe,我正在科尔多瓦开发一个Webview应用程序。此webview应用程序具有iframe,我将在其中显示我网站的内容 但是单击backbutton会重定向到上一页,而不是返回iframe页面 注意:在iframe中,每个页面都是通过ajax加载和更改的。在每一个ajax上,我们都会将url推送到浏览器状态。我也有同样的问题,对我有效的解决方案是一个简单的技巧。替换: <a data-rel="back" data-icon="back">back</a> by
注意:在iframe中,每个页面都是通过ajax加载和更改的。在每一个ajax上,我们都会将url推送到浏览器状态。我也有同样的问题,对我有效的解决方案是一个简单的技巧。替换:
<a data-rel="back" data-icon="back">back</a>
by
<a data-id="persistent" href="the page_before" data-transition="slide" data-icon="back"> back</a>
它工作得很好可能与此类似:您使用Jquery mobile吗?不,我只使用Jquery。
$( "#logout_btn" ).click(function() {
showToast('Logging Out', 'info');
console.log("Logout Button Clicked");
logout_user();
});
$( "#reload_btn" ).click(function() {
showToast('Reloading Page', 'info');
console.log("Reload Button Clicked");
$( '#main_content' ).attr( 'src', function ( i, val ) { return val; });
});
$( "#home_btn" ).click(function() {
console.log("Home Button Clicked");
$( '#main_content' ).attr( 'src','https://www.mycollegepicks.in/home?app=1&tab_type=home');
});
$( "#back_btn" ).click(function() {
console.log("Back Button Clicked");
iFrameHistory = document.getElementById("main_content").contentWindow.history.length;
if(iFrameHistory)
document.getElementById('main_content').contentWindow.history.back();
writeLog("iFrameHistory "+iFrameHistory);
PopeyeLogger('Iframe History Length '+iFrameHistory,'info');
});
$( "#forward_btn" ).click(function() {
console.log("Forward Button Clicked");
iFrameHistory = document.getElementById("main_content").contentWindow.history.length;
if(iFrameHistory)
document.getElementById('main_content').contentWindow.history.forward();
writeLog("iFrameHistory "+iFrameHistory);
PopeyeLogger('Iframe History Length '+iFrameHistory,'info');
});
<a data-rel="back" data-icon="back">back</a>
by
<a data-id="persistent" href="the page_before" data-transition="slide" data-icon="back"> back</a>