JavaScript的警报框中允许多少个字符 [英] How many characters allowed in an alert box in JavaScript

查看:61
本文介绍了JavaScript的警报框中允许多少个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道您在警报框中最多可以显示多少个字符?

Does anyone know what is the maximum number of characters you can display in an alert box?

我正在向用户返回错误警报,其中包含每个错误和警告的详细信息,但是显然,当数据过多时,该框将不再显示.这是我的一些代码:

I'm returning an error alert to the user with details for each of the errors and warnings but apparently the box just don't show up anymore when there is too much data. Here's some of my code:

<?php
    //Two arrays are created in php, one with the errors, one with the warnings.
?>

<script type="text/javascript">
    alert("<?php
         if(count($err) != 0){
             $errorfound = True;
             echo 'Error:\n\n';
             foreach($err as $message){
                 echo '\t' . $message . '\n';
             }
         }
         if(count($warn) != 0){
             echo '\n\nWarning:\n\n';
             foreach($warn as $mess){
                 echo '\t' . $mess . '\n';
             }
        }?>");
</script>

<?php
    //app continues if no error was found
?>

经过调查,我的问题并非出自警报框的容量,而是实际上我需要对消息进行addslashes()(这就是为什么我认为它使用较少的值的原因,但实际上我是很幸运,因为他们不是需要逃脱的角色). 我一定会更改警报框以使用更合适的方法,只是想说警报框没有问题.

After investigation, my problem didn't come from the capacity of the alert box but was in fact that I needed to addslashes() to my messages (that's why I thought it was working with fewer values, but in fact I was just lucky because they weren't characters that needed to be escaped). I'll definitely change that alert box for something more appropriated, just wanted to say that there is no problem with the alert box.

推荐答案

我个人不喜欢弹出警报.您可能会考虑使用页面内置的消息框,该消息框可以容纳无限量的内容,并且在出现错误时可以在屏幕上闪烁"几秒钟.

Personally I despise popup alerts. You might consider using a message box built into the page that can hold an indefinite amount of content, and can be "flashed" on the screen for a few seconds on error.

您可以选择禁用整个页面并使消息覆盖.原型或jQuery可以使任何一项任务快速完成.

You can optionally disable the entire page and make the message an overlay. Prototype or jQuery would make quick work of either task.

如果要查看禁用页面的示例,本文使用进度指示器,可以很容易地将其换成一条消息. http://edwardawebb.com/web-development/cakephp /disable-page-show-translucent-progress-bar

If you want to see an example of disabling the page, this article uses a progress indicator that could easily be swapped for a message. http://edwardawebb.com/web-development/cakephp/disable-page-show-translucent-progress-bar

这篇关于JavaScript的警报框中允许多少个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆