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

150
Views
Cómo obtener el valor de # URL con JavaScript

No puedo usar url Query https://example.com/?l=http://example2.com en mi servidor CloudFlare Worker.

Entonces, mi pregunta es cómo convertir este script JS para que funcione con https://example.com/#http://example2.com

 function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } var l = getUrlVars()["l"];

Basado en la respuesta de jp-jee, este es mi script:

 <script> var hash = window.location.hash; function change(){ var txt = hash.replace("#", ""); document.getElementById("url").value = txt; } </script> <input onclick="change()" name="url" type="text" id="url" placeholder="enter url here" value="enter url here" /> <button id="submit" onclick="submitURL()">Submit</button>

Gracias :)

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Utilice window.location.hash y elimine el carácter # del resultado.

Para la URL https://example.com/#http://example2.com , window.location.hash se evalúa como "#http://example2.com"

about 4 years ago · Santiago Trujillo Report

0

El # y el texto que le sigue se conocen como "fragmento" o "hash". La clase URL pone esto en la propiedad .hash .

Sin embargo, hay un problema diferente: este texto no se envía al servidor en HTTP regular, se guarda solo en el navegador. Eso significa que no puede ver este valor en Cloudflare Workers ni en ningún otro código del lado del servidor. Si desea utilizar # para la navegación, debe implementar su navegación en el lado del cliente, en el navegador.

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