ID:2084757
 
(See the best response by Lummox JR.)
I want to include every new line the players included on their texts, but I haven't found a way to do it with CSS.



Code:
<textarea class="textarea" id="Message">d</textarea>

</style type="text/css">
<script type="text/javascript">
function Create(){
Send('Create', document.getElementById('Message').value)}

function Send(action, _message) {
window.location="byond://?src=\ref[src]&action="+action+"&message="+_message;}


mob
Topic(href, list/href_list)
..()
var/A = href_list["action"]
world<< href_list["message"]


The message is displayed, but it ignores the new lines. Is there a way to fix it? Thanks :)
"&message=\""+encodeURIComponent(_message)+"\""
In response to Ter13
Ter13 wrote:
"&message=\""+encodeURIComponent(_message)+"\""

Sorry for bothering again, but I receive a script error with this:

    function Send(action, _name, _message) {
window.location="byond://?src=\ref[src]&action="+action+"&message=\""+encodeURIComponent(_message)+"\"";


Thanks again!
What's the script error?
In response to Ter13
Ter13 wrote:
What's the script error?

It displays a script error saying that it expected ";"
What's the exact error message?
   function Send(action, _name, _message) {
window.location="byond://?src=\ref[src]&action="+action+"&message=\""+encodeURIComponent(_message)+"\"";


I don't see a closing }.
I don't see a closing }.

Good eye, sir.
I forgot that } on the post, but it was included on the source, sorry about that :(

However, the script error I get is pretty much like this (with different url, ofc).

I'm not showing the one I'm getting because my native language isn't English, but I get the same error: "Expected ;"
Is the HTML you're sending actually what you've posted here, or did you build it inside of an extended string like this:

var/html = {"line1
line2
line3"}

If it's in an extended string, escaping some characters is still necessary, so it's possible that's what happened here. In particular I think you need to escape the backslash you used before the double quote.

However I honestly don't think you need the escaped quotes around the message parameter at all.
You're actually missing a semi-colon in the Create() function, at the end of the Send call.

You should probably also NOT put ending braces on the same line. They always go on a new line.

Also, is the code you pasted all in the same file?

You're kind of mixing HTML, JS and DM...
In response to Lummox JR
Lummox JR wrote:
Is the HTML you're sending actually what you've posted here, or did you build it inside of an extended string like this:

var/html = {"line1
> line2
> line3"}

If it's in an extended string, escaping some characters is still necessary, so it's possible that's what happened here. In particular I think you need to escape the backslash you used before the double quote.

However I honestly don't think you need the escaped quotes around the message parameter at all.

Hello, the script error did not appear without the code Ter13 wrote before. I simply want to display the text the way the players wrote it, with various lines, otherwise there wouldnt be new lines unless they exceeded textareas width. I added alert(_message) under javascripts function and it displayed the message correctly, but for some reason I cant manage to make it look the same on Topic().
Hello, the script error did not appear without the code Ter13 wrote before.

I'm uncertain if the escaped quotes were necessary. The encodeURIComponent() call is definitely necessary.
In response to Ter13
Ter13 wrote:
Hello, the script error did not appear without the code Ter13 wrote before.

I'm uncertain if the escaped quotes were necessary. The encodeURIComponent() call is definitely necessary.

The escaped quotes should make their way through the implicit params2list() call in Topic() intact, so I'd lose them. But yeah, encodeURIComponent() is very important.
Sorry for bumping this again, but I've tested various changes by removing escaped quotes, and it doesn't seem to trigger the effect I'm looking for. May I know how the function Send should have the _message part? Thanks in advance, and sorry for being annoying :( I would have not posted this if I had figured out a way to make it work by myself.
Best response
You need the encodeURIComponent() call around _message as Ter said, so that it will encode the _message var properly for a URL.

I believe the escaped quotes were causing your crash because you're building all of this HTML and JavaScript inside a DM extended string. In actual straight JS they wouldn't have caused a script error, but because they're not escaped properly for DM, that's why it happened. This would have been clearer if you'd posted the entire proc you're using to send the HTML to the browser.