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

283
Vistas
How to Get 10 from this link (https://google.com/?ib=10)

Check this image I have this link in (note this link not from search URL) var link = https://google.com/?ib=10 in main.js file. Now how to get that 10 from this link in javaScript on Page load

I have tried this way

var link1 = link;
const url3 = new URLSearchParams(link1);
    const ur = url3.get("ib");
    var finaltgid = ur;
    alert(ur);

But its not working may be this code only work when we use window.location.search Instead of var or const

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

0

urlsearchparams does not parse full url, you need to pass only query part, like this:

var link = 'https://google.com/?ib=10';
const url = new URLSearchParams(new URL(link).search);
const ib = url.get("ib");
console.log(ib);

about 4 years ago · Juan Pablo Isaza Denunciar

0

URLSearchParams only accepts the actual query part in the constructor. You are including the full link.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Edit: For a given link you can just supply the link in place of document.location (which directly fetches the pages current location)

Considering this as Vanilla JS. You can do the following.

let params = (new URL(document.location)).searchParams;

let ib = parseInt(params.get('ib')); // is the number 10

Note, using the parseInt to get the value as a number.

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