Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
Pass a non encoded string into a URL - Javascript

I am using this script to pass data from a form into a URL

Problem: the email is passed encoded and a %40 is added instead of the @

  • Any way to pass a non-encoded URL? I would like to pass the full email into the URL.

I need the full email because I use it then to populate a hidden field in a Typeform form.

Thanks a lot for your help :)

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
  hbspt.forms.create({
    portalId: "[PORTAL ID]",
    formId: "[FORM ID]"
  });
  // add custom script after it
  var array = [];
  window.addEventListener('message', event => {
    // in the onFormSubmit global form event, grab the data and push it to the above array
    if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
      let vars = ['firstname', 'lastname', 'email', 'phone', 'hs_language'];
      let len = vars.length;
      for (i = 0; i < len; i++) {
        for (j in event.data.data) {
          if (event.data.data[j]["name"] == vars[i]) {
            let object = {
              name: '',
              value: ''
            };
            object.name = vars[i];
            object.value = event.data.data[j]["value"];
            array.push(object);
          }
        }
      }
    }
    // after the form has submitted and data sent to Hubspot, get the data from the array and then redirect the page, adding the data to the URL
    if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
      var firstname = array[0].value
      var lastname = array[1].value
      var email = array[2].value
      var phone = array[3].value
      var lang = array[4].value
      window.location = "[URL TO REDIRECT TO HERE]?firstName=" + encodeURIComponent( firstname ) +"&lastName=" + encodeURIComponent( lastname ) +"&email=" + encodeURIComponent( email ) + "&phone=" + encodeURIComponent( phone ) + "&language=" + encodeURIComponent( lang );
    }
  });
</script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda