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

218
Views
Obtenga el valor de la variable de la página js proporcionada en la consola en JavaScript

Déjame explicarte cuál es el problema.

Soy nuevo aquí así que por favor ignoren mis errores. Haré todo lo posible para explicarme.

Tengo un webpage.html e incluí un script js como from script o puede estar dentro de la etiqueta <script> .

Guardé algo como var v ="my variable from a text box" dentro de la página web.

Ahora quiero el valor var v de la consola para ver su valor.

Lo intenté:

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

No funcionó para mí.

El javascript se está cargando durante el proceso de uso en la página web y el script es:

 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), }

Quiero este valor.multiLapJourneyDetails.clientTxnId cuando se ejecute

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

0

Si tiene una página html y coloca una variable llamada v dentro de un bloque de script, puede ver esa variable abriendo la consola y simplemente escribiendo v porque su variable está en el alcance de la window .

Por supuesto, también puede agregar una instrucción console.log(v) en su bloque de script, después de la declaración de v , para ver su valor automáticamente cuando abre la consola.

about 4 years ago · Juan Pablo Isaza Report

0

Dentro de la página web, haga window.myVar = "some value" en lugar de var myVar = "some value" .

 nightmare.evaluate(function () { return window.myVar; }).then(function(myVar) { // do something here })
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!