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

163
Vistas
How can you use an attribute tag to insert a variable from local storage to run a script

I have my javascript stored in a localstorage varibale as hackVariable defined below. hackVariable
begin:
">document.querySelector('[onclick="Hackbutton()";]').click();<img src='notexist.png'
end:

Then I have this html doc with the goal to trigger the click button after the hackVariable has been put in alt attribute of the image tag. The issue I'm facing is that the browser interprets the " as " in the variable hackVariable.

<!DOCTYPE html>
<html>
<body>

<p>This example uses the HTML DOM to try to click a button</p>

<img src="winner.jpg" alt="hackVariable" width="100" height="100" >

<button  type="button" id="Hackbutton" onclik="DoSomethingCrazy()"> Click Me!</button>

</body>
</html>

This is the result I get

<img src="winner.jpg" alt=" &quot;><script>document.querySelector('[onclick=*&quot;*Hackbutton()*&quot;*;]').click();</script><img src='notexist.png' width="100" height="132" >

This is what I want to get

<img src="winner.jpg" alt=" "><script>document.querySelector('[onclick="Hackbutton()";]').click();</script><img src='notexist.png' width="100" height="100" >

My goal is to try to prevent the browser from encoding the double quote " coming from the variable into " I tried few methods like replacing the " with &x22 or &#34; but didn't work.

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