473,231 Members | 1,937 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,231 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 1916
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.