473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

formatting text in JavaScript popup boxes

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

there is also few additional special characters:

\' single quote
\" double quote
\& ampersand
\\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed

Is there also additional characters for more reach formatting? (bold
text, etc)? Need we put "\n" inside quotations?
Is there some Javascript popup Alert box text formatter, to format text
from GUI, more handy way?

Apr 7 '06 #1
10 47460

ko****@hotmail.com wrote:
We can use special characters ('\n') to add line breaks in text in
JavaScript popup Alert boxes.

there is also few additional special characters:

\' single quote
\" double quote
\& ampersand
\\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed

Is there also additional characters for more reach formatting? (bold
text, etc)? Need we put "\n" inside quotations?
Is there some Javascript popup Alert box text formatter, to format text
from GUI, more handy way?


If you want graphics either open a window, or display a HTML element on
top of everything else on the page.

(I myself would use the last one)

Apr 7 '06 #2
My question was about the JavaScript popup Alert boxes.

<script type="text/javascript">
alert('Text');
</script>

Apr 7 '06 #3

kor...@hotmail.com wrote:
My question was about the JavaScript popup Alert boxes.

<script type="text/javascript">
alert('Text');
</script>


Right and I answerd you.

Btw: please quote the message you're responding to.

Apr 7 '06 #4
> kor...@hotmail.com wrote:
My question was about the JavaScript popup Alert boxes.

<script type="text/javascript">
alert('Text');
</script>
Right and I answerd you. Btw: please quote the message you're responding to.

--------------------------------------------

We can use special characters ('\n') to add line breaks in text in
JavaScript popup Alert boxes.
Is there also additional characters for more reach formatting? (bold
text, etc)? Need we put "\n" inside quotations?
Is there some Javascript popup Alert box text formatter, to format text

from GUI, more handy way?

Apr 7 '06 #5
ko****@hotmail.com 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():

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

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

<URL: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/>
Apr 7 '06 #6
Thomas 'PointedEars' Lahn писал(а):

ko****@hotmail.com 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/a...odaldialog.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

Apr 7 '06 #7
ko****@hotmail.com wrote:
We can use special characters ('\n') to add line breaks
in text in JavaScript popup Alert boxes. <snip> Is there also additional characters for more reach
formatting? (bold text, etc)? Need we put "\n" inside
quotations?
Is there some Javascript popup Alert box text formatter,
to format text from GUI, more handy way?


There is quite a wide school of thought that regards the alert, prompt
and confirm facilities of web browsers as utterly inappropriate and
inadequate for use in a real world GUI; that they are at best
learning/debugging tools and should never be exposed to the end user.
This is not least because they have inconsistent and extremely limited
(and largely undesirable) display characteristics.

Richard.
Apr 7 '06 #8
Thomas 'PointedEars' Lahn wrote:
ko****@hotmail.com wrote: <snip>
\& ampersand


Well, the same goes for \a, \c, \d and so on in string literals,


This is true.
because it is not a valid escape sequence.
This is questionable. Because \a is a valid EscapeSequence (ECMA 262,
3rd Ed. Section 7.8.4). The backslash followed by EscapeSequence, where
EscapeSequence is one of 0, CharacterEscapeSequence, HexEscapeSequence
or UnicodeEscapeSequence is a SingleStringCharacter. And
CharacterEscapeSequence is either SingleEscapeCharacter or
NonEscapeCharacter, where NonEscapeCharacter is any SourceCharacter that
is not an EscapeCharacter or LineTerminator.

So any character (with the explicit exception of LineTerminators)
preceded by a backslash may be a valid EscapeSequence but if the
character is not one of the set that is SingleEscapeCharacter the result
of the EscapeSequence is just the character itself.

\a is the equivalent of a, pointless but allowed by the syntax.
The ampersand does not
need to be escaped.
No it does not need to be escaped.

<snip> 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.

<snip>

True, but as I recall IE gets this wrong and treats \v as a literal v.
Still, how often have you used vertical tabs to date? For me it is
never, and that is one of the reasons that I use vertical tabs
('\u000B') as separators in strings that need to be split up using a
character separator, as alternatives such as |, ~, ^, etc. have proved
insufficiently unusual in the past.

Richard.
Apr 7 '06 #9
> Addind a quotations "\n" cause adding it also to text and new line
both, so it not required, probably.

----------------------
Hence, correct syntax is without double quotations, i.e. \n , \r , etc

Korund

Apr 7 '06 #10
JRS: In article <11**********************@t31g2000cwb.googlegroups .com>
, dated Fri, 7 Apr 2006 03:51:20 remote, seen in
news:comp.lang.javascript, ko****@hotmail.com posted :

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


AFAIK no, apart maybe from \v .

However, AFAICS no-one has yet mentioned the use of \uHHHH where H is a
hexadecimal digit - try alert("\u20ac") - though it may be that not many
of them work reliably (user font dependence).
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Apr 8 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: J?rgen Jensen | last post by:
I have made an asp-page. When pressing Submit, the form loads a javascript, for evaluating the input values. The asp-page is being reloaded from the javascript, to save the input-values. The...
3
by: Treetop | last post by:
I would like to pass text to a popup window to save creating a new html file for each help topic. I would like to have a value for the heading, a value for the text, code for printing the help...
3
by: Ike | last post by:
Does anyone know where I can find example scritp for formatting text input? I want to have a text box where only legitiamte filesname under unix can be netered (no whitespace, only alphanumeric,...
5
by: Paul Krasucki | last post by:
This is for a search page that takes parameters on one page, processes the query, and displays them on another page. I've got a javascript popup window on a button click event. When the user...
3
by: stevenc417 | last post by:
The popup works fine on Firefox 1.5.0.9, but it doesn't work on IE7. It just re-acts like a regular link on IE7. Any ideas anyone? Thanks, Steven ...
3
by: DavidPr | last post by:
I'm using this javascript: <script type='text/javascript' language='JavaScript'> function PopUp(url) {...
2
by: one.1more | last post by:
I want to make a text game using javascript dialog boxes. i learned about confirm boxes but its not helpful(http:// www.javascriptmall.com/learn/lesson6.htm) 1. for ex, in the confirm boxes,...
3
by: pavanip | last post by:
Hi, I have written the code for display popup window using javascript in button onclient click event. <asp:Button ID="Button1" runat="server" Style="position: static"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.