Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 28th, 2006, 11:08 PM   #1
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
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:
Clicks per hour: 123 Clicks per day: 456 Link Clicks: 789/250 Power gained yesterday:987
without the newlines that should be there from all the \n. Any idea why? I Googled, and \n seems to be the newline in JavaScript.

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
Intimidat0r is offline   Reply With Quote
Old Jan 28th, 2006, 11:14 PM   #2
oNe8
Newbie
 
oNe8's Avatar
 
Join Date: Jan 2006
Posts: 17
Rep Power: 0 oNe8 is on a distinguished road
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);
oNe8 is offline   Reply With Quote
Old Jan 29th, 2006, 1:24 AM   #3
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
It gives me the same result.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Old Jan 29th, 2006, 10:27 AM   #4
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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.
__________________

tempest is offline   Reply With Quote
Old Jan 29th, 2006, 1:03 PM   #5
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
That works, thank you very much tempest.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:21 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC