Javascript 警报消息替代

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5810740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 19:00:27  来源:igfitidea点击:

Javascript alert message Alternative

javascriptjquery

提问by Satch3000

On my online page I have a simple alert message. I basically need to change the title but I've read that I cannot do that.

在我的在线页面上,我有一条简单的警报消息。我基本上需要更改标题,但我已经读到我不能这样做。

Here's the code:

这是代码:

<script>alert("My Message Here");</script>

In the alert message I get the url of my website and then the message under it.

在警报消息中,我得到了我网站的 url,然后是它下面的消息。

What is the quickest alternative to having a javascript alert?

拥有 javascript 警报的最快替代方法是什么?

Thanks

谢谢

采纳答案by John Hartsock

回答by sorrymissHymanson

I like this one a lot: http://t4t5.github.io/sweetalert/

我非常喜欢这个:http: //t4t5.github.io/sweetalert/

It does not depend on any other JavaScript library and is highly customizable. Supports different kinds of message pop-ups, implements a prompt pop-up and allows message chaining.

它不依赖于任何其他 JavaScript 库并且是高度可定制的。支持多种消息弹窗,实现提示弹窗,并允许消息链接。

回答by Ady Ngom

A very lightweight version of what you are trying to achieve can be found in this cool plugin:

您可以在这个很酷的插件中找到一个非常轻量级的版本:

http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

回答by Thorsten Staerk

If you quickly want to output debugging information, just write it into a div element. For example to write width and height when resizing the window:

如果你想快速输出调试信息,只需将其写入一个 div 元素即可。例如在调整窗口大小时写入宽度和高度:

<html>
<script language=javascript>
window.onresize = function(event) 
{
  document.getElementById("debug").innerHTML=window.innerWidth+"x"+window.innerHeight;
}
</script>
<div id="debug">
  Resize your Window to start.
</div>
</html>

回答by Rory McCrossan

The alternative is a javascript 'modal window'. Having a google for that should turn up a plethora of options.

另一种选择是javascript“模态窗口”。有一个谷歌应该会出现很多选择。

This method enables you to style a div however you like and to have that shown in place of the alert box. If you've ever seen a lightbox, the effect and idea is very similar.

此方法使您可以根据自己的喜好设置 div 的样式,并将其显示在警告框的位置。如果你见过灯箱,效果和想法是非常相似的。

They are all very easy to implement. Most often just requiring the inclusion of the script, some CSS and a line of jquery to initialise the modal window on the specific DIV.

它们都很容易实现。大多数情况下只需要包含脚本、一些 CSS 和一行 jquery 来初始化特定 DIV 上的模式窗口。

回答by Michael Schinis

I know im a bit late on this.. But i was looking for exactly the same thing, and came up with Jquery Plugin Appriseand Jquery Plugin MD

我知道我在这方面有点晚了..但我一直在寻找完全相同的东西,并提出了Jquery Plugin AppriseJquery Plugin MD