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

169
Vistas
Print JS Variable in HTML

I would like to output a JS variable to HTML. Until now I have attached it to the URL and then truncated it. unfortunately other things like this don't work and I would like to pass the Label variable directly into 'Tablet_name'. Is this possible? Here is the JS code with the var label.

function search_period(period, max_num, offset) {
    var count = 0;
    var link = ""
    var div = document.createElement('div')
    var h2 = document.createElement('h2')
    var iiif = ""
    h2.innerHTML = period
    document.body.appendChild(h2)
    const keys = Object.keys(urls);
    for(const elem of keys) {
        var label = urls[elem].label
        for(const el of urls[elem].variants) {
            if(el.label.includes('front')) {
                iiif = el.url
            }
        }
        if(!periods.hasOwnProperty(label)) {
            continue;
        }
        if(periods[label] != period) {
            continue;
        }
        if(count < offset) {
            count+=1
            continue
        }
        link = changeIIIFInformation(iiif, 10, "default")
        var figure = document.createElement('figure')
        var figcaption = document.createElement('figcaption')
        var linkToImage = document.createElement('a')
        //linkToImage.setAttribute('#image', label)
        linkToImage.setAttribute('href', 'annotator#'+label)
        linkToImage.innerHTML = label
        figcaption.appendChild(linkToImage)
        var image = document.createElement('img')
        
        image.setAttribute('src', link)
        figure.appendChild(image)
        figure.appendChild(figcaption)
        div.appendChild(figure)
        count += 1;
        if(count >= max_num+offset) {
            break;
        }
    }
    document.body.appendChild(div)
}

And here is the HTML Code:

var tablet_name = ""
  var default_tablet_link = ""
  if(document.URL.includes('#')) {
    tablet_name = document.URL.split('#')[1]
  } else {
    tablet_name = 'HS_0044'
  }

I want the for the tablename the variable label.

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