How many characters allowed in an alert box in JavaScript

前端 未结 4 2026
一整个雨季
一整个雨季 2020-12-07 01:04

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 erro

4条回答
  •  自闭症患者
    2020-12-07 01:22

    I don't know about limits in alert(), but I'm pretty sure that your code will produce an JS-syntax error.

    Especially keep in mind that you cannot simply use strings in multiple lines in javascript. Please show us the output of your PHP-script.

    Examples:

    //will not work
    alert('this
           is
           an 
           alert');
    
    //This will work:
    alert('this '+
           'is '+
           'an '+
           'alert');
    
    //this works too:
    alert('this \
           is \
           an \
           alert');
    

提交回复
热议问题