如<a href="#popupBasic" data-rel="popup" data-role="button" data-inline="true" data-transition="pop">Basic Popup</a>
<div data-role="popup" id="popupBasic">
<p>This is a completely basic popup, no options set.</p>
</div>打开方式
$(document).ready(function(){
$('a').click();
});
<div data-role="popup" id="popupBasic">
<p>This is a completely basic popup, no options set.</p>
</div>打开方式
$(document).ready(function(){
$('a').click();
});
解决方案 »
- JavaScript如何动态添加table的行
- 我写的JS的代码,不知道什么错误
- 请大家支持一下我这只有10分的人吧,浮动广告问题!!!!!
- 如何清空<td> 内或者<div>内中的所有内容?
- javaScript中怎样才能更好的实现指针,可以不通过建立object的方式吗
- 我怎样才能得到一个对像的XY坐标?例如一个文字,一张图片,一个按钮,在线等,急,谢谢
- 跨域能不能取到opener的属性?
- 关于将网页中的部分内容下载为word 的问题,请各位大快来指教!!!!!急啊急啊急啊
- 如何使<input type=text readonly=true>
- vue 中通过methods生成div
- 菜鸟问个jquery关于append的问题
- 分享一个模拟64位整数类(实现大小比较,+-法,支持负数)
不要a 连接,只要<div data-role="popup" id="popupBasic">
<p>This is a completely basic popup, no options set.</p>
</div>
然后执行$("#popupBasic").popup('open');为什么不行呢?
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script>
$(document).ready(function(){
$("#popupBasic").popup('open');
});
</script>
</head>
<body><div data-role="page" id="pageone">
<div data-role="header">
<h1>在此处插入标题</h1>
</div> <div data-role="content">
<p>在此处插入正文</p>
<div data-role="popup" id="popupBasic">
<p>This is a completely basic popup, no options set.</p>
</div>
</div> <div data-role="footer">
<h1>在此处插入页脚文本</h1>
</div>
</div> </body>
</html>
//提示信息
function showmsg(title,content,link,times){
if($("#showmsg").length==0){
var showmsgdiv = '<div class="piaofu" data-role="popup" id="showmsg" data-theme="a" class="ui-content"> <div class="piaofu_title" id="showtitle">'+title+'</div> <div class="piaofu_con" id="showcontent">'+content+'</div></div>';
var $popup = $(showmsgdiv);
}else{
var $popup = $("#showmsg");
$("#showtitle").html(title);
$("#showcontent").html(content);
} //$popup.popup({ history: true });
$popup.popup();
$popup.popup('open');
if(typeof(times)=="number" && times>0){
var msgshow = setTimeout(function(){
$popup.popup('close');
if(typeof(link)!='undefined' && link!=''){
self.location = link;
}
},times);
}
}写了一个 js 的提示加跳转函数,
<a href="javascript:test()">test</a>function test(){
showmsg("test","test_content","index.html",20000);
}
这样执行就正常。
按照下面的方式来执行,就不会弹出。在IE浏览器里面提示jquery 文件错误,在google 浏览器里面没有弹出,只进行了跳转操作,在火狐浏览器里面一切正常,在手机端和google浏览器的表现一样只跳转,没有弹出。<!DOCTYPE html>
<html>
<head>
<title>test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="js/jquery-1.10.2.min.js"></script>
<link type="text/css" rel="stylesheet" href="js/jquery.mobile-1.4.5.min.css" >
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).ready(function(){
showmsg("test","test","index.html",2000);
})//提示信息
function showmsg(title,content,link,times){
if($("#showmsg").length==0){
var showmsgdiv = '<div class="piaofu" data-role="popup" id="showmsg" data-theme="a" class="ui-content"> <div class="piaofu_title" id="showtitle">'+title+'</div> <div class="piaofu_con" id="showcontent">'+content+'</div></div>';
var $popup = $(showmsgdiv);
}else{
var $popup = $("#showmsg");
$("#showtitle").html(title);
$("#showcontent").html(content);
} //$popup.popup({ history: true });
$popup.popup();
$popup.popup('open');
if(typeof(times)=="number" && times>0){
var msgshow = setTimeout(function(){
$popup.popup('close');
if(typeof(link)!='undefined' && link!=''){
self.location = link;
}
},times);
}
}
</script>
<body>
</body>
</html>
$popup.popup({closeEvents:false});
试了一下,没问题。
是 jqm1.4.5么,jquery版本是 1.10.2的,还是我这还是不行
重新试了一下,自动弹出不会关闭了,但是需要点击两次空白处才能关闭,而且URL变化和原来的不同,后面会跟出很长的参数
关闭代码相对没那么复杂,options也都是可以重新设置的,如果是那个参数引起的,关闭前能够再设置参数。
如果不好使,可以自己继承该组件,自己重写。