admin管理员组文章数量:1288055
I have a link like this
<a href='/path/to/popup.html' data-role="button">COME HERE </a>
I want to open the popup.html file as a jquery popup.
And I cant have it inside the current page as a <div>
with an id. I must have it out side the current file.
And I cant use dialog's as it reloads the current page.
Any idea on how to do it?
Inside the popup.html I am using just a single header.
Or any methods through which I can avoid the page being reloaded when dialog is closed?
I have a link like this
<a href='/path/to/popup.html' data-role="button">COME HERE </a>
I want to open the popup.html file as a jquery popup.
And I cant have it inside the current page as a <div>
with an id. I must have it out side the current file.
And I cant use dialog's as it reloads the current page.
Any idea on how to do it?
Inside the popup.html I am using just a single header.
Or any methods through which I can avoid the page being reloaded when dialog is closed?
Share
Improve this question
asked Feb 8, 2014 at 0:55
user3283104user3283104
4163 gold badges5 silver badges14 bronze badges
0
3 Answers
Reset to default 4Use .load()
to load popup.html into a placeholder (i.e <div id="PopupPH">
). This placeholder can be placed either inside data-role="page
or outside it, depending on jQuery Mobile version you are using.
Moreover, in popup.html, you need to change data-role=page"
to data-role="popup
in order to treat it as a popup not a page.
jQuery Mobile 1.4
Insert placeholder inside body
tag or data-role="page"
and load popup.html.
<body>
<div data-role="page">
</div>
<div id="PopupPH">
<!-- placeholder for popup -->
</div>
</body>
Or
<body>
<div data-role="page">
<div id="PopupPH">
<!-- placeholder for popup -->
</div>
</div>
</body>
Load popup.html into placeholder
$("#PopupPH").load("popup.html");
Inside popup.html popup div, add JS to create, open and remove popup once it's closed.
<div data-role="popup">
<!-- contents -->
<script>
$("[data-role=popup]").enhanceWithin().popup({
afterclose: function () {
$(this).remove();
}
}).popup("open");
</script>
</div>
jQuery Mobile 1.3 and below
Do the same as above, except for popup placeholder should be inside data-role="page"
, because jQM 1.3 doesn't support external popup. Also, replace .enhanceWithin()
with .trigger("create")
.
Using the frames & popups in jQuery mobile, you can simply include an iframe inside, although dialogs are still probably your better bet. (Especially as a click outside the popup.. kills it)
<div class="hidden">
<div data-role="popup" id="externalpage">
<iframe src="http://www.bbc."
width="480"
height="320"
seamless>
</iframe>
</div>
</div>
<a href='#externalpage'
data-rel="popup"
data-role="button">COME HERE</a>
<script>
$(document).on("pageinit", function() {
$( "#externalpage" ).on({
popupbeforeposition: function( event, ui ) {
console.log( event.target );
}
});
});
</script>
Demo: http://jsfiddle/tcS8B/ jQuery Mobile Dialogs don't refresh the page I don't think, it simply masks it with a new background for focused attention.
Try
<a href="google." rel="external">Test</a>
本文标签: javascriptHow to open an external html page as a popup in jquery mobileStack Overflow
版权声明:本文标题:javascript - How to open an external html page as a popup in jquery mobile? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741333771a2372921.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论