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

205
Vistas
How to link JavaScript and HTML5 pages without <script> tag?

I am trying to make a button for my webpage that changes the ENTIRE colour palette of the page with Code.org AppLab. The only problem is, code.org doesn't allow the use of the <script> tag for "security reasons". As far as I know the only way I can turn on CSS settings with a button is with getElementById(). If anyone knows how to activate CSS settings when a button is clicked without JS, how to link external JS files to an html file, or use inline JS all WITHOUT the use of the <script> tag please show me how.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

HTML attributes. It may be blocked as well, but it's worth giving a try. See this example:

<!--It's not necessary, but it'd be easy to put all your scripts inside a template tag or the like-->
<template id="script" style="display:none">
alert("Hello, world! JavaScript has been injected");
document.getElementById("btn").style.cssText = `
  padding: 5px 10px;
  border: none;
  background-color: orange;
  color: white;
  font-family: 'Segoe UI', sans-serif;
`;
</template>
<button id="btn" onclick="(Function(document.getElementById('script').innerHTML))()">Inject JavaScript</button>

A similar approach to the above is to inject a script tag:

<!--It's not necessary, but it'd be easy to put all your scripts inside a template tag or the like-->
<template id="script" style="display:none">
alert("Hello, world! JavaScript has been injected");
document.getElementById("btn").style.cssText = `
  padding: 5px 10px;
  border: none;
  background-color: orange;
  color: white;
  font-family: 'Segoe UI', sans-serif;
`;
</template>
<button id="btn" onclick="const s=document.createElement('script');s.innerHTML=document.getElementById('script').innerHTML;document.body.appendChild(s);">Inject JavaScript</button>

If all else fails, you could also use an <a> tag and execute JavaScript as a URL (this example won't work when you're running it on StackOverflow due to their whatever):

<!--It's not necessary, but it'd be easy to put all your scripts inside a template tag or the like-->
<template id="script" style="display:none">
alert("Hello, world! JavaScript has been injected");
document.getElementById("btn").style.cssText = `
  padding: 5px 10px;
  border: none;
  background-color: orange;
  color: white;
  font-family: 'Segoe UI', sans-serif;
`;
</template>
<!--Prefix JavaScript URLs with "javascript:"-->
<a href="javascript:(Function(document.getElementById('script').innerHTML))()" id="btn">Inject JavaScript</a>

about 4 years ago · Santiago Trujillo Denunciar
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