473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiline alert not working

23 New Member
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 1945
gits
5,390 Recognized Expert Moderator Expert
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 New Member
ohh, thank you very much. It works great now!
Sep 17 '07 #3
dmjpro
2,476 Top Contributor
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 Recognized Expert Moderator Expert
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
1951
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 of escaping the \n's. A repr function that output triple-quoted strings with explicit (non-escaped) linebreaks would be perfect.
0
2350
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 copiedto TEXTAREA on main HTML window: wndTxtArea.value = dlgTxtArea.value; Then user may take the text for editing in HTML dialog windowonce more. The problem arises when text to be copied is multiline. Firsttime it is displayed properly after...
4
31049
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 seems to be working. Code like
2
1364
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 multiple tabs but when I did my project would abort when I tried to run it. I tried the same thing under Visual Studio 6 and it worked fine so I copied the working project to .Net 2003, compiled it and it also works ok but when I checked the...
2
4599
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 correct font/size until the text mode is changed from single line to multiline. We're currently using the H1, H2, H3 and Body tags for the page.
40
4611
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 nest properly. ML has a very elegant system for nested comments with (* and *). Using an editor to throw #s in front of every line has limitations. Your editor has to support it and you have to know how to use that feature. Not exactly...
11
5062
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 this: I get a multiline string returned to Javascript from a Proxy+Google Maps API GDownloadUrl() The data, when added to a DOM table looked fine, about 20 lines in CSV format
6
3793
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 = open("filename").read() multilinePattern = "^<tag.... <\/tag>$" re.search(multilinePattern, where, re.MULTILINE)
5
6280
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
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.