Re: formatting text in JavaScript popup boxes



Thomas 'PointedEars' Lahn писал(а):

korund@xxxxxxxxxxx wrote:

We can use special characters ('\n') to add line breaks in text in
JavaScript popup Alert boxes.

True.

there is also few additional special characters:

\' single quote
\" double quote

Those are not special characters in any way. They are escape sequences
required only when the escaped character already serves as a string literal
delimiter.

\& ampersand
Well, the same goes for \a, \c, \d and so on in string literals, because it
is not a valid escape sequence. The ampersand does not need to be escaped.

\\ backslash

Again, that is not a special character, but an escape sequence for the
backslash character, which serves as escape sequence prefix itself
(hence the requirement to escape it if the literal character is needed).

\n new line
\r carriage return
\t tab
\b backspace
\f form feed

That is true, and the characters displayed by those escape
sequences are the only special characters you mentioned.

ECMAScript Edition 3 also defines the escape sequence

\v (equivalent to \u000B)

for the <VT> (Vertical Tab) character (U+000B). See ECMAScript Edition 3
Final, subsection 7.8.4.

Is there also additional characters for more reach formatting? (bold
text, etc)?

No.

Need we put "\n" inside quotations?

I do not know if you have to; I have, as I prefer to have running code.
\n is an escape sequence valid within (string and RegExp) literals only.

Is there some Javascript popup Alert box text formatter, to format text
from GUI, more handy way?

No. You will have to create your own popup window. There are some
proprietary approaches, such as showModalDialog() in the IE DOM, that
support you in creating modal windows as you know them from window.alert():

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp

Gecko-based UAs have window.open(..., ..., "modal") and window.openDialog():

http://developer.mozilla.org/en/docs/DOM:window#Methods

But none of these is interoperable.

And to save you another Frequently Asked Question (FAQ[1]): it is
utter nonsense to try to simulate that behavior with window.open()
by programmatically trying to force the focus on the popup window,
because that is very likely to make the rest of the GUI unusable.

PointedEars
___________
[1] <URL:http://jibbering.com/faq/>
------------------------------------------------------
Addind a quotations "\n" cause adding it also to text and new line
both, so it not required, probably.

Korund

.



Relevant Pages

  • Re: online awk application - viable
    ... feasibility of writing a web application to carry out pattern matching in ... The main problems are that the browser will escape some characters in the ... # character for the original escape sequence. ... # Hex is a string in the form \xnn where n is in the set 0-9a-f. ...
    (comp.lang.awk)
  • Re: online awk application - viable
    ... feasibility of writing a web application to carry out pattern matching in ... be implemented in php or another language but awk (which I have not used ... The main problems are that the browser will escape some characters in the ... # character for the original escape sequence. ...
    (comp.lang.awk)
  • Re: Unrecognized escape sequences in string literals
    ... But in this case, Python is making ... least not if it doesn't have any escape characters in it that I'm not ... it would never be the case in C++ code that the programmer who ... didn't know that "\xba" was an escape sequence, ...
    (comp.lang.python)
  • Re: x and strings
    ... >> The escape sequence for embedded bytes is three characters following ...
    (microsoft.public.vc.language)
  • Re: Open Office Suite
    ... has been used as page layout program with lots of graphics or lots of special ... Powerpoint compatibility depends upon the ... and special characters in the type. ...
    (comp.sys.mac.advocacy)