本文目录一览:
- 1、怎么样通过js实时弹出新消息提示框并有音响起的实现代码
- 2、php中信息发布成功跳出JS提示框代码
- 3、Ext js的弹出各种消息代码
- 4、点击上传,发表,发起,话题,发起这五个链接词时,怎样用js控制弹出一个消息框显示一句话,重点js该怎样
怎么样通过js实时弹出新消息提示框并有音响起的实现代码
1、加入语音提示
audio id="sound" autoplay="autoplay"
动态加入播放语音文件代码:
document.getElementById("sound").src="%=basePath%admin/media/global.wav";
2、动态弹出消息提示框:
在此处我导入了jquery.gritter.js和jquery.gritter.css,具体实现代码:
jQuery(document).ready(function() {
setInterval(function(){
$.post('ajax/linecheck',function(data){
var json=eval("("+data+")");
$.each(json,function(index,item){
$("#line"+item.id).html("")
$.each(item.localList,function(index,item2){
if(item2.attendOCList!=""){
$("#line"+item.id).append("li class='in' id='in"+item2.id+"'div class='avatar'"
+item2.location+"/divdiv class='message'ul id=li"+item2.id+"/ul/div/li")
}
$.each(item2.attendOCList,function(index,item3){
if(item3.status==0){
$("#li"+item2.id).append("li class='user'span class='username'"+item3.person_name
+"/spanbrspan style='color:red;' class='username'时间: "
+ item3.today+" "+item3.times +"/spanbrspan class='username'电话:"
+item3.person_phone+"/spanbrspan class='username'身份证:"
+item3.card_id+"/span/lihr");
}else{
$("#li"+item2.id).append("li class='user'span class='username'"
+item3.person_name+"/spanbrspan style='color:red;' class='username'时间: "
+ item3.today+" "+item3.times +"/spanbrspan class='username'电话:"
+item3.person_phone+"/spanbrspan class='username'身份证:"
+item3.card_id+"/span/lihr");
document.getElementById("sound").src="%=basePath%admin/media/global.wav";
setTimeout(function () {
var unique_id = $.gritter.add({
title: item3.person_name+"("+item2.location+")",
text:"span class='username'"+item3.person_name
+"/spanbrspan style='color:red;' class='username'时间: "
+ item3.today+" "+item3.times +"/spanbrspan class='username'电话:"
+item3.person_phone+"/spanbrspan class='username'身份证:"+item3.card_id+"/span",
sticky: true,
time: '',
class_name: 'my-sticky-class'
});
setTimeout(function () {
$.gritter.remove(unique_id, {
fade: true,
speed: 'slow'
});
}, 12000);
}, 2000);
}
});
});
php中信息发布成功跳出JS提示框代码
PHP 弹出JS 提示框示例代码:
?php
header("Content-type:text/html;charset=utf-8;");
$conn=mysql_connect("localhost","root","root");
if(!$conn){
die("数据库连接出错。".mysql_error());
}
mysql_select_db("test");
$sql="insert into table(id,name)values(1,'chinawinxp')";
$int=mysql_query($sql);
//信息添加或者发布成功
if($int){
$msg="信息发布成功!";
echo ("script type='text/javascript'");
echo ("alert('{$msg}');");
//url跳转
echo ("location.href='test.php';");
echo ("/script");
}
?
运行效果:
Ext js的弹出各种消息代码
/**
* 弹出一般消息,有时间限制
*/
xJsonTool.prototype.showMsg = function (msg, time) {
Ext.MessageBox.show({
title: '提示',
msg: msg,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
setTimeout(function(){Ext.MessageBox.hide();},time);
};/**
* 弹出提示消息
*/
xJsonTool.prototype.info = function (msg, vfn) {
Ext.MessageBox.show({
title: '提示',
msg: msg,
fn:vfn,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
};/**
* 弹出警告消息
*/
xJsonTool.prototype.warn = function (msg, vfn) {
Ext.MessageBox.show({
title: '警告',
msg: msg,
fn:vfn,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.WARNING
});};/**
* 弹出错误信息
*/
xJsonTool.prototype.error = function (msg, vfn) {
Ext.MessageBox.show({
title: '错误',
msg: msg,
fn:vfn,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});};/**
* 弹出确认信息
*/
xJsonTool.prototype.confirm = function (msg,vfn) {
Ext.MessageBox.show({
title: '确认消息',
msg: msg,
width:300,
buttons: Ext.MessageBox.OKCANCEL,
fn: function(btn){
if(btn=='ok')
if(vfn)
vfn(btn);
},
icon: Ext.MessageBox.QUESTION
});
};
点击上传,发表,发起,话题,发起这五个链接词时,怎样用js控制弹出一个消息框显示一句话,重点js该怎样
我举个例子a href="cp.php?ac=upload" class="gray"
name="shangchuanBlum" onfocus="checkLimit" onclick="checkLimit()"上传/a
改成
a href="javascript:;" class="gray" name="shangchuanBlum" onclick="checkLimit(1)"上传/a
然后
function checkLimit(t){
if(xxxx){
alert('你没登陆!!!');
return false;//或者window.location调到登陆页
}else{
if(t==1){
window.location.href="cp.php?ac=upload";
}
}
}