/*
* 提示信息获取与修改
* 陈安一
*/
//弹出提示框
function showaa(object) {
var id = object.id;
var url = "http://url/tips/" + window.location.hostname + window.location.pathname + "/" + id;
$("<script src=‘" + url + "‘><" + "/script>").appendTo($("body"));//这个url是有返回数据的
//获取用户信息
$("<script src=\"http://xxxxx\"></script>").appendTo($("body"));
var msg = "<input id=\"changetip\" type=\"text\" /><br /><input type=\"button\" bid=\"" + id + "\" value=\"修改\" type=\"button\" bid=\"" + id + "\" value=\"显示\" onclick=\"getJ(this);\">";
//TIP是上面那个url返回的json数据
if (TIP != undefined && TIP != null) {
//layer插件
layer.tips(msg, object, {
style: [‘background-color:#78BA32; color:#fff‘, ‘#78BA32‘],
time: 60,
closeBtn: [0, true]
});
}
}
//获取 + 提交修改数据
function getToken(obj) {
var id = $(obj).attr("bid");
var action = "http://url/tips/" + window.location.hostname + window.location.pathname + "/"+id;
//需要修改的tip值
var tip = document.getElementById("changetip").value;
var myDate = new Date();
//创建表单跨域提交数据
var form = document.createElement("form");
var iframe = document.createElement("iframe");
iframe.id = "id_iframe";
iframe.name = "id_iframe";
iframe.style.display = "none";
//将iframe设为不可见的。要不然会跳转到新页面
document.body.appendChild(form);
document.body.appendChild(iframe);
document.clear(iframe);
var i1 = document.createElement("input");
i1.type = "hidden";
form.appendChild(i1);
i1.value = YUAN_USER.token;
i1.name = "token";
var i2 = document.createElement("input");
i2.type = "hidden";
form.appendChild(i2);
i2.value = tip;
i2.name = "tip";
var i3 = document.createElement("input");
i3.type = "hidden";
form.appendChild(i3);
i3.value = window.location.host;
i3.name = "referer";
var i4 = document.createElement("input");
i4.type = "hidden";
form.appendChild(i4);
i4.value = myDate.getTime();
alert(i4.value);
i4.name = "time";
var i5 = document.createElement("input");
i5.type = "hidden";
form.appendChild(i5);
i5.value = YUAN_USER.loginname;
i5.name = "creater";
form.action = action;
form.method = "post";
form.target = "id_iframe";
form.submit();
}
// 根据id值获取提示信息
function getJ(obj) {
var id = $(obj).attr("bid");
var url = "http://url/tips/" + window.location.hostname + window.location.pathname + "/" + id;
if (TIP != undefined && TIP != null) {
layer.tips(TIP.tip, obj, {
style: [‘background-color:#78BA32; color:#fff‘, ‘#78BA32‘],
time: 60,
closeBtn: [0, true]
});
}
}
页面
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<script src="~/Scripts/require.js"></script>
@*引用layer*@
<script src="~/Scripts/Plugin/Layer/layer.min.js"></script>
<script src="~/Scripts/Plugin/Layer/layerHelper.js"></script>
</head>
<body>
<div>
<button id="sbbbbb" /><br /><br />
<button id="sddddd" /><br /><br />
</div>
<script>
</script>
@*顶部代码就是这个msgdiv*@
<script src="~/Scripts/alert/msgdiv.js"></script>
</body>
</html>