inherit
111576
0
Jul 13, 2013 18:59:12 GMT -8
perishingflames
112
September 2007
perishingflames
|
Post by perishingflames on Oct 21, 2009 19:06:35 GMT -8
How can I use document.write javascript to write multiline css? Does \n work for line breaks?
document.write("<style type='text/css'>.welcomebg {background-image: url(http://i92./l14/Perishingflames/Picture37.png);}\n.titlebg {background-image: url(http://img329.imageshack.us/img329/2595/goldjo3vn7.gif);}</style>");
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Oct 21, 2009 19:16:08 GMT -8
Do you have to have it multiline - I don't get what you're trying to achieve.
|
|
inherit
111576
0
Jul 13, 2013 18:59:12 GMT -8
perishingflames
112
September 2007
perishingflames
|
Post by perishingflames on Oct 21, 2009 19:18:41 GMT -8
Haha actually just realized that right before you posted this
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Oct 21, 2009 19:26:33 GMT -8
You would need separate document.write()s..
document.write('<style type="text/css">.welcomebg {background-image: url(http://i92./l14/Perishingflames/Picture37.png);}</style>'); document.write('<style type="text/css">.titlebg {background-image: url(http://img329.imageshack.us/img329/2595/goldjo3vn7.gif);}</style>");
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Oct 21, 2009 19:30:40 GMT -8
You would need separate document.write()s.. document.write('<style type="text/css">.welcomebg {background-image: url(http://i92./l14/Perishingflames/Picture37.png);}</style>'); document.write('<style type="text/css">.titlebg {background-image: url(http://img329.imageshack.us/img329/2595/goldjo3vn7.gif);}</style>");
That's not multiline - as pointed out previously, there's no advantage to multiline in this point, or any need for it.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Oct 21, 2009 19:31:31 GMT -8
Oh, lol, I am half-awake, half-asleep. Nm on my post lol
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Oct 21, 2009 20:56:56 GMT -8
Multiple document.writes doesn't make multiple lines. As said, multiline isn't necessary.
But, to answer the original question, yes \n will work (in double quotes, not in single quotes) for making a new line if you ever need to for whatever reason.
|
|
inherit
111576
0
Jul 13, 2013 18:59:12 GMT -8
perishingflames
112
September 2007
perishingflames
|
Post by perishingflames on Oct 22, 2009 12:07:34 GMT -8
Yeah I just did
document.write("<style type='text/css'>.welcomebg {background-image: url(http://i92./l14/Perishingflames/Picture37.png);}.titlebg {background-image: url(http://img329.imageshack.us/img329/2595/goldjo3vn7.gif);}</style>");
|
|
jadw2k9
inherit
-3772057
0
Dec 3, 2024 21:57:12 GMT -8
jadw2k9
0
January 1970
GUEST
|
Post by jadw2k9 on Oct 31, 2009 11:31:56 GMT -8
If you want it multi-line so you can see it more clearly? Yes, that's possible. See below:
document.write("<style type='text/css'>"+ ".welcomebg {background-image: url(http://i92./l14/Perishingflames/Picture37.png);}"+ ".titlebg {background-image: url(http://img329.imageshack.us/img329/2595/goldjo3vn7.gif);}</style>");
By the way, the "\n" makes no difference to the code. When the code is compiled and run, it's all treated as though it's written on a single line. That's why every statement/command has to end with a semi-colon.
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Oct 31, 2009 20:55:58 GMT -8
The \n most certainly makes a difference. Not noticable to the viewer, since whitespace isn't [always] displayed. \n isn't part of the JavaScript, it's part of the HTML. Times where \n would be noticable, for example, would be in a <pre> tag. document.write("<pre>This is\npreformatted\ntext.<\/pre>"); In stylesheets, if you use <!-- and --> inside the <style>, there has to be a linebreak between the comment tags and the code itself (probably not in all browsers, but I've ran into that error before). So, document.write("<style type=\"text/css\"><!--\n.code { sexy : stuff; }\n--><\/style>"); In his example, he wasn't using comments, so it wasn't necessary. But for someone who is, it is. And in alert() messages, which don't take HTML, alert("This message is\non multiple lines.");
It's not needed for most cases, but it's worth knowing and has its uses.
|
|
jadw2k9
inherit
-3773128
0
Dec 3, 2024 21:57:12 GMT -8
jadw2k9
0
January 1970
GUEST
|
Post by jadw2k9 on Nov 1, 2009 11:06:25 GMT -8
You may have a point.
Though, \n wouldn't have made a difference in the bit of code posted by OP. But I'm sure OP will find your examples useful regardless - especially as I have no idea what other CSS he/she is putting in that document.write().
|
|