The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
3 posters

    Quoting, editing problems

    Zzbaivong
    Zzbaivong
    Forumember


    Posts : 101
    Reputation : 51
    Language : JavaScript ^^

    Pro Admin Quoting, editing problems

    Post by Zzbaivong June 25th 2015, 2:52 pm

    I have a code:
    Code:
    var jsCodes = "<img src=\"http://r29.imgfast.net/users/3412/19/22/63/smiles/45347.png\" />";
    Note backslash: \"

    I can preview and submit without errors. However, when I quote or edit this post, the backslash will disappear. This causes the error to my code.

    To test, try quoting this post.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Pro Admin Re: Quoting, editing problems

    Post by SLGray June 26th 2015, 4:11 am

    Do you exactly need those in the code?



    Quoting, editing problems Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Zzbaivong
    Zzbaivong
    Forumember


    Posts : 101
    Reputation : 51
    Language : JavaScript ^^

    Pro Admin Re: Quoting, editing problems

    Post by Zzbaivong June 26th 2015, 5:18 am

    SLGray wrote:Do you exactly need those in the code?
    I don't understand you. I'm reporting a problem in SCEditor.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Pro Admin Re: Quoting, editing problems

    Post by SLGray June 27th 2015, 4:25 am

    I mean that I believe you do not need the backlashes?



    Quoting, editing problems Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Zzbaivong
    Zzbaivong
    Forumember


    Posts : 101
    Reputation : 51
    Language : JavaScript ^^

    Pro Admin Re: Quoting, editing problems

    Post by Zzbaivong June 27th 2015, 10:44 am

    I think that is not the way to solve the problem. Because my forum is also a lot of other people who also share their code.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Pro Admin Re: Quoting, editing problems

    Post by Ange Tuteur June 27th 2015, 10:57 am

    The backslash "\" is commonly used in programming as an escape character. With JavaScript it can be used in string literals to use the same kind of quotation marks inside it without ending the string.

    Example :
    Code:
    var str = 'Let's go to the park!'; // syntax error

    The string ended before "s", because the quotation mark was recognized as the end of the string literal. Using the escape character gets passed this problem.
    Code:
    var str = 'Let\'s go to the park!'; // All good :)


    Into the topic.. That's a problem, but for the moment I'd recommend using a different kind of quote for the attributes, such as the single.
    Code:
    var jsCodes = "<img src='http://r29.imgfast.net/users/3412/19/22/63/smiles/45347.png' />";

    or swap it :
    Code:
    var jsCodes = '<img src="http://r29.imgfast.net/users/3412/19/22/63/smiles/45347.png" />';
    Zzbaivong
    Zzbaivong
    Forumember


    Posts : 101
    Reputation : 51
    Language : JavaScript ^^

    Pro Admin Re: Quoting, editing problems

    Post by Zzbaivong June 27th 2015, 11:01 am

    I know that. Thanks for your enthusiasm.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Pro Admin Re: Quoting, editing problems

    Post by Ange Tuteur June 27th 2015, 12:01 pm

    The explanation on the backslash wasn't directed towards you. Dawa

    From what I can tell, the backslash in my post didn't disappear. I'm assuming it's only with certain characters ? ( i.e. double quote ) I'm just going to leave a few test below to see.

    Code:
    "<div id=\"noId\"></div>";
    "A \"normal\" string.";

    '<div id=\'noId\'></div>';
    'A \'normal\' string.';
    Zzbaivong
    Zzbaivong
    Forumember


    Posts : 101
    Reputation : 51
    Language : JavaScript ^^

    Pro Admin Re: Quoting, editing problems

    Post by Zzbaivong June 27th 2015, 12:02 pm

    Ange Tuteur wrote:The explanation on the backslash wasn't directed towards you. Dawa

    From what I can tell, the backslash in my post didn't disappear. I'm assuming it's only with certain characters ? ( i.e. double quote ) I'm just going to leave a few test below to see.

    Code:
    "<div id="noId"></div>";
    "A "normal" string.";

    '<div id=\'noId\'></div>';
    'A \'normal\' string.';
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Pro Admin Re: Quoting, editing problems

    Post by Ange Tuteur June 27th 2015, 12:02 pm

    Yeah, it's only the double quote as I thought. I'll report it to see if they can do anything about it.

      Current date/time is November 11th 2024, 8:28 pm