parmi une série d'URLComment supprimer tous les paramètres et le nom de domaine d'une URL à l'aide de javascript?
http://www.anydotcom.com/myfolder/some-url.html http://www.anydotcom.com/myfolder2/index.html# http://www.anydotcom.com/myfolder3/index.html?someParam=aValue http://www.anydotcom.com/foldername/index.html?someParam=anotherValue
Tout d'abord, comment pourrais-je enlever quoi que ce soit de la fin de l'URL afin que je me retrouve avec
http://www.anydotcom.com/myfolder/some-url.html http://www.anydotcom.com/myfolder2/index.html http://www.anydotcom.com/myfolder3/index.html http://www.anydotcom.com/foldername/index.html
ou, idéalement, je voudrais à revenir
/myfolder/some-url.html /myfolder2/index.html /myfolder3/index.html /foldername/index.html
J'ai essayé
var thisUrl = "" + window.location; var myRegExp = new RegExp("([^(\?#)]*)"); thisUrl = myRegExp.exec(thisUrl);
mais cela revient
http://www.anydotcom.com/foldername/index.html,http://www.anydotcom.com/foldername/index.html
et je ne comprends pas bien pourquoi.
J'apprécie n'importe quelle aide ici!
Ugh. C'est ce que je reçois pour ne pas complètement vérifier l'objet de localisation. Merci pour la réponse rapide. –
Et merci à l'autre, aussi correct, réponses. –