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

212
Vistas
Get variable value from supplied js page in the console in JavaScript

Let me explain what is the issue.

I am new here so please ignore my mistakes. I will try my best to explain myself.

I am having a webpage.html and I included a js script like from script or may be inside <script> tag.

I saved something like var v ="my variable from a text box" inside the webpage.

Now I want the var v value from the console to view the value of it.

I tried:

nightmare.evaluate(function () {
// now we're executing inside the browser scope.
return window.YOUR_VARIABLE;
}).then(function(YOUR_VARIABLE) {
// use the value
})

Did not worked for me.

The javascript is loading during the using process in webpage and the script is :

initAvlFareEnq(e) {
                var t = 0;
                (Array.isArray(e.avlFareResponseDTO) ? e.avlFareResponseDTO : Array.of(e.avlFareResponseDTO)).forEach(e=>{
                    if (null == e.errorMessage && null == e.errorMessage) {
                        e.avlDayList = Array.isArray(e.avlDayList) ? e.avlDayList : Array.of(e.avlDayList);
                        
                        this.multiLapJourneyDetails.lapDetails.push(i)
                    } else
                        this.messageService.add({
                            life: this.langService.life,
                        })
                }
                ),
                this.multiLapJourneyDetails.mainJourneyTxnId = this.jpInput.txnId,
                this.multiLapJourneyDetails.clientTxnId = (new Date).getTime().toString(36),
                
            }

I want this.multiLapJourneyDetails.clientTxnId value when its get executed

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you have an html page and you put a variable called v inside a script block, you can see that variable opening the console and simply writing v because your variable is in window scope.

Of course you can also add a console.log(v) statement in your script block, after the declaration of v, in order to see his value automatically when you open the console.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Inside the webpage, do window.myVar = "some value" instead of var myVar = "some value".

nightmare.evaluate(function () {
    return window.myVar;
}).then(function(myVar) {
    // do something here
})
about 4 years ago · Juan Pablo Isaza 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