![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Hobbyist Programmer
|
newline in javascript
var power_msg = "Clicks per hour: 123\nClicks per day: 456\nLink Clicks: 789/250\nPower gained yesterday:987\n"; document.write(power_msg); This just prints: Quote:
I also tried with \r (it said that was for Windows) but it had the same effect. Any help would be appreciated. Thanks!
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jan 2006
Posts: 17
Rep Power: 0
![]() |
I never written much javascript but i do i heavy amount of just Java and that seems like it should work you could try going
var power_msg = "Clicks per hour: 123" +"\n" + "Clicks per day: 456" +"\n"+"Link Clicks: 789/250 Power"+ "\n" +"gained yesterday:987"; document.write(power_msg);
__________________
http://img523.imageshack.us/img523/8436/user9kz.jpg |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
It gives me the same result.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
You're writing HTML to the document...
document.write = function(str) {
document.body.appendChlid(document.createTextNode(str));
}
var power_msg = "Clicks per hour: 123<br />\n" +
"Clicks per day: 456<br />\n" +
"Link Clicks: 789/250 Power<br />\n" +
"gained yesterday: 987<br />\n";
document.write(power_msg);There seems to be a spacing problem when it displays "createTextNode" there is no space there. document.write() is 3vil.
__________________
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
That works, thank you very much tempest.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|