javascript question, textbox space and carriage return added

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lezinterracial
    Confirmed User
    • Jul 2012
    • 3117

    #1

    javascript question, textbox space and carriage return added

    javascript question, space and carriage return added to the output text.

    I am working on a chrome extension that encodes text. But a space and carriage return are being added to the output. Anybody know why?

    example
    http://nicecamgirls.com/popup.htm
    Live Sex Shows
  • lezinterracial
    Confirmed User
    • Jul 2012
    • 3117

    #2
    my code
    Code:
    <body>
    <script>
    
    function encodeFunction() {
     var x;
     x = document.getElementById("inputtext").value;	
     if(document.getElementById('urlEncodecheck').checked){   
        var encodex;
        encodex = encodeURIComponent(x);
     }
     if(document.getElementById('HTMLEncodecheck').checked){   
        var encodex;
        encodex =  x.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
     }                                                          
     if(document.getElementById('hexencodecheck').checked){
        var s = unescape(encodeURIComponent(x))
        var encodex = ''
        for (var i = 0; i < s.length; i++) {
            encodex += "%" + s.charCodeAt(i).toString(16)
        }}
     if(document.getElementById('base64Encodecheck').checked){
        var encodex = '';
        encodex = window.btoa(x);
       }
    
      document.getElementById("outputttext").value = encodex;
     }
    </script>
    
    <h1>Encode</h1>
    
    <form action="">
      <input type="radio" name="encodetype" id="urlEncodecheck" checked="checked" oninput="encodeFunction()">Url<br>
      <input type="radio" name="encodetype" id="base64Encodecheck" oninput="encodeFunction()">Base64<br>
      <input type="radio" name="encodetype" id="HTMLEncodecheck" oninput="encodeFunction()">HTML<br>
      <input type="radio" name="encodetype" id="hexencodecheck" oninput="encodeFunction()">Hex
    <h2>Input</h2>
    <textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus>
     
    </textarea>
    <h2>Output</h2>
    <textarea id="outputttext" rows="4" cols="50" readonly>
    </textarea>
    </body>
    Live Sex Shows

    Comment

    • sarettah
      see you later, I'm gone
      • Oct 2002
      • 14295

      #3
      The extra shit is coming from your textarea. The way you coded the textarea puts spaces and the line feed in there. Just put the textarea close right up against the open and the extra shit should go away.


      <textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus></textarea>


      .
      All cookies cleared!

      Comment

      • CurrentlySober
        Too lazy to wipe my ass
        • Aug 2002
        • 38941

        #4
        i%20like%20poo%20%0A

        aSBsaWtlIHBvbyAK

        i like poo

        %69%20%6c%69%6b%65%20%70%6f%6f%20%a


        👁️ 👍️ 💩

        Comment

        • sarettah
          see you later, I'm gone
          • Oct 2002
          • 14295

          #5
          Originally posted by sarettah
          The extra shit is coming from your textarea. The way you coded the textarea puts spaces and the line feed in there. Just put the textarea close right up against the open and the extra shit should go away.


          <textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus></textarea>

          BTW, if any one cares. "extra shit" is the technical term for that extra shit

          .
          All cookies cleared!

          Comment

          • lezinterracial
            Confirmed User
            • Jul 2012
            • 3117

            #6
            Originally posted by sarettah
            The extra shit is coming from your textarea. The way you coded the textarea puts spaces and the line feed in there. Just put the textarea close right up against the open and the extra shit should go away.


            <textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus></textarea>


            .
            You are awesome sarettah. I really should have seen that.
            Live Sex Shows

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14295

              #7
              Originally posted by lezinterracial
              You are awesome sarettah. I really should have seen that.
              One of those dumb mistakes that we all make.

              I spent a couple of hours the other day tracking down an issue. Turned out to be an errant semi colon.

              File it under things that make me go: "Duh".

              ;p

              .
              All cookies cleared!

              Comment

              Working...