Javascript jQuery移动个人加载特定于每个页面的消息
在jQuery Mobile中,在给定页面上是否可能有不同的加载消息 我正在使用mobile.loadingMessage,我也尝试了mobile.showPageLoadingMsg,但我找不到这个问题的答案 下面是我在应用程序中显示的消息:Javascript jQuery移动个人加载特定于每个页面的消息,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,在jQuery Mobile中,在给定页面上是否可能有不同的加载消息 我正在使用mobile.loadingMessage,我也尝试了mobile.showPageLoadingMsg,但我找不到这个问题的答案 下面是我在应用程序中显示的消息: $(document).bind('mobileinit',function(){ $.extend($.mobile, { loadingMessage: "We're processing yo
$(document).bind('mobileinit',function(){
$.extend($.mobile, {
loadingMessage: "We're processing your request. We won't be long. Just Like Great Food, a good hotspot takes time to (find) prepare for you....",
pageLoadErrorMessage: 'Sorry, there was an error while loading!',
});
$.mobile.page.prototype.options.addBackBtn = true;
});
您可以监听
pageshow
事件,并设置特定于该页面的加载消息
示例代码:
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Sample</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
$("#page1").live("pageshow",function(){
$.mobile.loadingMessage = "Loading message for page1";
});
$("#page2").live("pageshow",function(){
$.mobile.loadingMessage = "Loading message for page2";
});
$(".showBtn").live("click",function(){
$.mobile.showPageLoadingMsg();
setTimeout(function(){$.mobile.hidePageLoadingMsg()},2000);
});
</script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<div data-role="page" id="page1">
<div data-role="header">
<h1>Page1</h1>
</div><!-- /header -->
<div data-role="content">
<a data-role="button" class="showBtn">Show loading message</a>
<a data-role="button" href="#page2">Go to page 2</a>
</div>
</div><!-- /page -->
<div data-role="page" id="page2">
<div data-role="header">
<h1>Page2</h1>
</div><!-- /header -->
<div data-role="content">
<a data-role="button" class="showBtn">Show loading message</a>
<a data-role="button" href="#page1">Go to page 1</a>
</div>
</div>
</body>
</html>
以及此表单的相应脚本
$("gotopage2).live("click",function(){
$.mobile.loadingMessage = "Loading message for page1";
$.mobile.changePage("page2.html");
});
让我知道这是否有用。这是我使用简单javascript和html元素加载页面消息的另一种方法。 我的博客: 你可以访问我的博客获取全文 此处的示例代码:
$function getpage(val)
{
hideFrame();
var mframe;
mframe=document.getElementById("MyFrame");
mframe.src=val;
mframe.onload=function()
{
document.getElementById("MyFrame").style.display="block";
document.getElementById("loadingDiv").style.display="none";
}
}
function hideFrame()
{
document.getElementById("MyFrame").style.display="none";
document.getElementById("loadingDiv").style.display="block";
}
function showFrame()
{
document.getElementById("MyFrame").style.display="block";
document.getElementById("loadingDiv").style.display="none";
}
function showdiv()
{
document.getElementById("loadingDiv").style.display="block";
}
function changeHome(val)
{
window.location=val;
}
$ <table>
<tr>
<td>
<div class="menu_div" onclick="getpage('http://www.aspnetsample.blogspot.in')">
Page1
</div>
</td>
<td>
<div class="menu_div" onclick="getpage('http://www.w3schools.com/css/default.asp')">
Page2
</div>
</td>
<td>
<div class="menu_div" onclick="getpage('page2.aspx')">
Page3
</div>
</td>
<td>
<div class="menu_div" onclick="changeHome('page3.aspx')">
Page4
</div>
</td>
</tr>
</table>
$ <iframe class="iframe" id="MyFrame" src="http://www.w3schools.com" onprerender="javascript:showdiv()"
onload="javascript:showFrame()" style="display: none;"></iframe>
<div id="loadingDiv" class="loadingDiv">
<table style="width: 100%; height: 100%;">
<tr>
<td align="center" valign="middle">
Page is Loading...
</td>
</tr>
</table>
</div>
$function getpage(val)
{
hideFrame();
var-mframe;
mframe=document.getElementById(“MyFrame”);
mframe.src=val;
mframe.onload=函数()
{
document.getElementById(“MyFrame”).style.display=“block”;
document.getElementById(“loadingDiv”).style.display=“无”;
}
}
函数hideFrame()
{
document.getElementById(“MyFrame”).style.display=“无”;
document.getElementById(“loadingDiv”).style.display=“block”;
}
函数showFrame()
{
document.getElementById(“MyFrame”).style.display=“block”;
document.getElementById(“loadingDiv”).style.display=“无”;
}
函数showdiv()
{
document.getElementById(“loadingDiv”).style.display=“block”;
}
功能更改主页(val)
{
window.location=val;
}
$
第1页
第2页
第3页
第4页
$
页面正在加载。。。
您必须在执行时删除该符号
要获得完整的代码,请访问我的博客嗨,谢谢!但是,有没有一种方法可以显示和隐藏链接到另一个页面,并在页面加载时停止?你说的是我给出的设置超时吗?这只是为了说明消息在加载弹出窗口中已更改。
$function getpage(val)
{
hideFrame();
var mframe;
mframe=document.getElementById("MyFrame");
mframe.src=val;
mframe.onload=function()
{
document.getElementById("MyFrame").style.display="block";
document.getElementById("loadingDiv").style.display="none";
}
}
function hideFrame()
{
document.getElementById("MyFrame").style.display="none";
document.getElementById("loadingDiv").style.display="block";
}
function showFrame()
{
document.getElementById("MyFrame").style.display="block";
document.getElementById("loadingDiv").style.display="none";
}
function showdiv()
{
document.getElementById("loadingDiv").style.display="block";
}
function changeHome(val)
{
window.location=val;
}
$ <table>
<tr>
<td>
<div class="menu_div" onclick="getpage('http://www.aspnetsample.blogspot.in')">
Page1
</div>
</td>
<td>
<div class="menu_div" onclick="getpage('http://www.w3schools.com/css/default.asp')">
Page2
</div>
</td>
<td>
<div class="menu_div" onclick="getpage('page2.aspx')">
Page3
</div>
</td>
<td>
<div class="menu_div" onclick="changeHome('page3.aspx')">
Page4
</div>
</td>
</tr>
</table>
$ <iframe class="iframe" id="MyFrame" src="http://www.w3schools.com" onprerender="javascript:showdiv()"
onload="javascript:showFrame()" style="display: none;"></iframe>
<div id="loadingDiv" class="loadingDiv">
<table style="width: 100%; height: 100%;">
<tr>
<td align="center" valign="middle">
Page is Loading...
</td>
</tr>
</table>
</div>