samedi 9 mai 2015

Javascript/jQuery hash URL doesn't execute

I have a hash URL that doesn't execute the javascript/jQuery unless I manually hit the enter key or refresh the page.

$(function($){
  var key=$(location).attr('hash');

  if (key){
    $('#div').find('div.div2').load('sig.php?k='+key)
  }
});

This works fine when I type in the URL manually or refresh the page but whenever I use <a href="url#SecReTkEy"> or Javascript/jQuery functions such as:

$(location).attr('href','url#SecReTkEy');

$('a').prop('href','url#SecReTkEy');

window.location.replace('url#SecReTkEy');

window.location.href('url#SecReTkEy');

Can any one tell me why and how to fix this? `

Aucun commentaire:

Enregistrer un commentaire