欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

手机端自己写js消息提示

程序员文章站 2024-03-05 15:39:43
...

原博主:https://blog.csdn.net/summer_my_sunshine/article/details/79196163 

window.alertMsg = function (txt) {
  var alertFram = document.createElement("DIV");
  alertFram.id = "alertFram";
  alertFram.style.position = "fixed";
  alertFram.style.width = "100%";
  alertFram.style.textAlign = "center";
  alertFram.style.top = "40%";
  alertFram.style.zIndex = "10001";
  strHtml = " <span style=\"font-family: 微软雅黑;display:inline-block;background:#333;color:#fff;padding:0 20px;line-height:36px;border-radius:6px; \">" + txt + "</span>";
  alertFram.innerHTML = strHtml;
  document.body.appendChild(alertFram);
  setTimeout((function () {
    alertFram.style.display = "none";
  }), 2000);
};

把上面这段写入一个新的js用script引入

使用的时候用

alertMsg('啦啦啦')

相关标签: 消息提示