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

195
Views
Cómo volver a Windows si el valor de JS es nulo

No tengo experiencia en JS, pero necesito ayuda.

Así que tengo un código que le permite a un usuario ingresar manualmente una URL.

Bueno, si dejan el valor en blanco y hacen clic en "NULLS". Quiero una forma de detectar ese nulo y volver a "/" o a la misma página en lugar de /null

 function url(){ swal("Enter a URL:", { content: "input", }) .then((value) => { location.replace(value); }); } // PROD Fix, needs a zero-null failure-fix. Find a way to prevent zero-data/null.

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Puede agregar una prueba para el valor nulo antes de location.replace() y cambiar el valor a la URL que desee como predeterminada.

 function url(){ swal("Enter a URL:", { content: "input", }) .then((value) => { if (value === null) value = "your replacement url"; location.replace(value); }); }
about 4 years ago · Santiago Gelvez Report

0

Tenga cuidado con la comprobación if (value === null) si puede recibir un valor nulo o una cadena vacía. La condición fallará si recibe una cadena vacía.

En su lugar, usaría if (!value) para cubrir tanto nulo && "".

about 4 years ago · Santiago Gelvez 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!