在警告框中允许多少个字符 - javascript [英] How many characters allowed in an alert box - javascript

查看:112
本文介绍了在警告框中允许多少个字符 - 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天全站免登陆