在index.html页面中调用外部HTML页面时页眉和页脚位置不固定?
我在jquery mobile的index.html页面中调用一个外部html页面时遇到页眉和页脚问题。 以下是我遵循的示例代码:
的index.html
.. ..
main.js
$("header").attr("data-position","fixed").attr("data-tap-toggle","false"); $("footer").attr("data-position","fixed").attr("data-tap-toggle","false");
https://stackoverflow.com/questions/10578545/header-footer-positions-not-fixed-when-calling-external-html-page-in-index-htm/sample.html
...... ..
在上面的index.html页面中调用“#single”和“#faq”时,页眉和页脚正确显示其位置是否已修复,但是当调用https://stackoverflow.com/questions/10578545/header-footer-positions-not-fixed-when-calling-external-html-page-in-index-htm/sample.html(外部HTML页面)时,页眉和页脚位置未显示在固定职位。 他们在动。
问题在于您调用attr()方法的时间。 您需要绑定到pagebeforecreate。 这样,在JQM增强标记之前,会设置页眉和页脚属性。 即
$(document).on('pagebeforecreate', function(){ $("header").attr("data-position","fixed").attr("data-tap-toggle","false"); $("footer").attr("data-position","fixed").attr("data-tap-toggle","false"); });
注意:如果您的jQuery版本是1.7之前的版本,请使用bind或delegate而不是on()
- 如何在PhoneGap / Android中实现DATE PICKER?
- Jquery,$ ajax和Android
- 当我设置错误的凭据时,为什么我的http basic auth请求获得状态0? Phonegap Android
- IScroll包装器没有达到高度
- html5video标签未能在phonegap android中使用cordova 2.9.0和jquery1.9.0播放.mp4video?
- 未知的铬误差:-6
- PhoneGap 1.5.0 Android Cordova AJAX JSON
- E / Web控制台(8272):未捕获的ReferenceError:未定义functionName:1在View Pager中加载webviews时
- 使用PhoneGap在Android上自动呼叫预定义号码