I want to create an alert with two lines
Today's Date
Sat March 3 12:35:58 EST 2012
I have used syntax alert("Today's date is : </br> "+dt);
and alert("Today's date is : "+<br />dt);
But none is working. Is it possible to create two line alert ? If yes, how ?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >
<head>
<title>Javascript Assignment 1</title>
<script type="text/javascript">
function backgcolor(){
document.bgColor="#ff0000";
}
function txtcolor(){
document.fgColor='green';
}
function alertfn(){
alert("This is test alert");
}
function displayDate(){
var dt = new Date();
alert("Today's date is : "+dt);
}
function writeDate(){
var dt = new Date();
document.write(dt);
}
</script>
</head>
<body>
<p>
<input type="button" value="Change Background Color" onclick="backgcolor()" />
<input type="button" value="Change Text Color" onclick="txtcolor()" />
<input type="button" value="Test Alert" onclick="alertfn()" />
<input type="button" value="Get Date" onclick="displayDate()" />
<input type="button" value="Write Date" onclick="writeDate()" />
<br /><br />
Unlike Java, C++ doesn't incorporate a debugger into every application. If you need one you have to provide it. Your compiler typically has one.
Just start it up and run your application. Car.cpp:381:runtime_exception:Could not find the brake Police.cpp:123:traffic_observation_exception: Speed too high
Driver.cpp:2131:existential_exception:I am in jail. If you happen to be developing on a system like Linux, then you could use one of many utilities such as electric fence. These are designed to
provide the platform specific capabilities you seem to be looking for, ∧ unless I'm mistaken, they tie into GDB. Well, I want this stack trace as a final output for the end user. I am
writing a kind of compiler where I process user input. I have a parser that reads user input and constructs sth called Items or int primitives
</p>
</body>
</html>
alerts don't understand HTML. they understand text and character entities. the character entity for a line return is:
Code:
\n
e.g.
Code:
alert("test\ntest")
alert("test\n\ntest")
etc.
1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.
to expound, the backslash is the escape sequence, and the "n" is the character code for a line return. if you type "\\", you'll see a single backslash in an alert, for instance.
1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.
Bookmarks