473,320 Members | 1,865 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,320 software developers and data experts.

multiline alert not working

23
I have this alert that works:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var monitor = setTimeout("alert('The monitor is working!');",0);
  3. </script>
  4. </head>
But I want to turn the alert message into a multiline alert, and when I do this:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var monitor = setTimeout("alert('The monitor is working!\n\ntest line two');",0);
  3. </script>
  4. </head>
It doesn't work, any ideas what I'm missing here?

-- PS the timeout is set to 0 for testing purposes only, otherwise it would have a value of 10000
Sep 17 '07 #1
4 1920
gits
5,390 Expert Mod 4TB
hi ...

you have to escape the backslahes for the linefeed:

Expand|Select|Wrap|Line Numbers
  1. setTimeout("alert('The monitor is working!\\n\\ntest line two');",0)
kind regards
Sep 17 '07 #2
Z1P2
23
ohh, thank you very much. It works great now!
Sep 17 '07 #3
dmjpro
2,476 2GB
hi ...

you have to escape the backslahes for the linefeed:

Expand|Select|Wrap|Line Numbers
  1. setTimeout("alert('The monitor is working!\\n\\ntest line two');",0)
kind regards
Why should I put double slashes?
Please let me know !

Kind regards,
Dmjpro.
Sep 17 '07 #4
gits
5,390 Expert Mod 4TB
the normal and better way would be:

Expand|Select|Wrap|Line Numbers
  1. setTimeout(function() { alert('test\nline2') }, 0)
as you can see here we may use the single slash. but when using:

Expand|Select|Wrap|Line Numbers
  1. setTimeout("alert('test\nline2')", 0)
javascript tries to evaluate the string and we get an unterminated string literal:

Expand|Select|Wrap|Line Numbers
  1. alert('test\n
i think it evals it as a linefeed in our js-code ... so we have to escape the slash again:

Expand|Select|Wrap|Line Numbers
  1. setTimeout("alert('test\\nline2')", 0)
and now it is working.

kind regards
Sep 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rasmus Fogh | last post by:
Dear All, I need a way of writing strings or arbitrary Python code that will a) allow the strings to be read again unchanged (like repr) b) write multiline strings as multiline strings instead...
0
by: Krzysztof Fink-Finowicki via .NET 247 | last post by:
I have problem with TEXTAREA HTML tags in my Web application (MSIE 6.0). User fills-in content of TEXTAREA on HTML dialog window. After accepting, content of TEXTAREA from dialog window is...
4
by: Michael C | last post by:
Hi all, I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example): Line1 Line2 Line3 I've tried a couple of methods but nothing...
2
by: C.McCullough | last post by:
It appears that the multiline and border properties of a tab control in the IDE on Visual Studio .Net 2003 are broken. I wanted to set the multiline property of my tab control to true to enable...
2
by: Chris | last post by:
Hi We are using style sheets to set the font of our labels and text boxes. This has been working great until we required a text box with a textmode of Multiline. The control picks up the...
40
by: Edward Elliott | last post by:
At the risk of flogging a dead horse, I'm wondering why Python doesn't have any multiline comments. One can abuse triple-quotes for that purpose, but that's obviously not what it's for and doesn't...
11
by: Brian | last post by:
I have been working on a data reception system.. I am still finding my way around Javascript, though I am accomplishing much. I just fixed a flaw that was really hard to find. The symptoms are...
6
by: Zdenek Maxa | last post by:
Hi all, I would like to perform regular expression replace (e.g. removing everything from within tags in a XML file) with multiple-line pattern. How can I do this? where =...
5
by: vjsv2007 | last post by:
Can you help to make one alert with all details? <script type="text/javascript"> <!-- function validate_form ( ) { valid = true;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.