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

108
Views
Controlador de eventos para ejecutar jQuery basado en URL

¿Existe un controlador de eventos jQuery que ejecute un script si la página tiene una determinada URL? Similar a $( document ).ready(function() { pero solo si la página tiene una URL particular.

Quiero ejecutar un script cuando la página esté lista, pero solo para una página con URL '.../algo/algo más/'.

La vista tiene enlaces que redirigen a nuevas URL para cambiar los aspectos del diseño, pero es la misma vista (estoy usando el marco web Django)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar window.location como a continuación: -

Un ejemplo:-

 if(window.location.href =='http://stacksnippets.net/js'){ console.log(window.location.hostname); console.log(window.location.href); }else{ $('#getHostNameandHref').html(window.location.hostname +'----'+window.location.href); console.log('other page'); }
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="getHostNameandHref"><div>

Nota: puede verificar console.log(window.location); para ver qué opciones disponibles hay que puede usar. Gracias

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!