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

查看:21
本文介绍了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:

';
             foreach($err as $message){
                 echo '	' . $message . '
';
             }
         }
         if(count($warn) != 0){
             echo '

Warning:

';
             foreach($warn as $mess){
                 echo '	' . $mess . '
';
             }
        }?>");
</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.

您可以选择禁用整个页面并使消息成为叠加层.Prototype 或 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天全站免登陆