Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Javascript [ documento.escribir ("___"); ] Atajo para no comenzar cada línea con document.write ("o alguna alternativa

En este código, quiero insertar algo de HTML y texto normal en JavaScript y no quiero que siempre ingrese document.write(" al comienzo de cada línea de esta manera:

 document.write ("<Style>"); document.write ("html {height:100%}"); document.write (".header {background-color: Aliceblue}"); document.write ("</Style>"); document.write ("<Div class='header'>Website Name</div>"); document.write ("<P style='color:red'>Some text i gathered here</p>");

Sería de gran ayuda si alguien pudiera resolver este problema o darme alguna alternativa.😊😊😊

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Puedes escribir todo a la vez usando ``:
 document.write(` <style> html {height:100%} .header {background-color: Aliceblue}" </style> <div class="header">Website Name</div> <p style="color:red">Some text i gathered here</p> `)
  1. Puede crear una función para él y llamarlo donde lo necesite:
 <script> function write(data) { document.write(data) } </script> ... <script> write("<style>"); write("html {height:100%}"); ... </script>

Advertencia:

  • escribe los nombres de las etiquetas en minúsculas:
 <Style> -> wrong <style> -> ok
  • No use las mismas comillas dentro y fuera de la cadena:
 "<div class="header">Website Name</div>" -> err "<div class='header'>Website Name</div>" -> ok
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!