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

147
Vistas
How to Get # URL value with JavaScript

i cant use url Query https://example.com/?l=http://example2.com on my CloudFlare Worker server.

So, My question is, how to convert this JS script to work with 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"];

Based on jp-jee reply, this my 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>
    

Thanks :)

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Use window.location.hash and remove the # character from the result.

For the URL https://example.com/#http://example2.com, window.location.hash evauates to "#http://example2.com"

about 4 years ago · Santiago Trujillo Denunciar

0

The # and text following it is known as the "fragment" or "hash". The URL class puts this in the property .hash.

However, there is a different problem: This text is not sent to the server in regular HTTP -- it is kept only in the browser. That means that you cannot see this value in Cloudflare Workers or any other server-side code. If you want to use # for navigation, you must implement your navigation on the client side, in the browser.

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