je veux obtenir l'ID de la barre d'URL et l'insérer dans le hrefURL id Bar = 1 Dans ID jQuery
$ («un [send_message.php 'href =? Act = h & id = $ id '] "). colorbox ({largeur:" 500 ", hauteur:" 350 ", iframe: true});
je veux obtenir l'ID de la barre d'URL et l'insérer dans le hrefURL id Bar = 1 Dans ID jQuery
$ («un [send_message.php 'href =? Act = h & id = $ id '] "). colorbox ({largeur:" 500 ", hauteur:" 350 ", iframe: true});
il y a un plugin jquery pour faire de ce ridiculement simple:
voir: http://plugins.jquery.com/project/query-object
par exemple
var id = $.query.get('id');
$("a[href='send_message.php?act=pm&id="+id+"']").colorbox({width:"500", height:"350", iframe:true});
Pour ceux qui n'utilisant jQuery ou tout autre bibliothèque JS:
var searchString = document.location.search;
// strip off the leading '?'
searchString = searchString.substring(1);
var gvPairs = searchString.split("&");
var getVars = [];
for (i = 0; i < gvPairs.length; i++)
{
var gvPair = gvPairs[i].split("=");
getVars[gvPair[0]] = gvPair[1];
}
Donc, si la chaîne URL est index.php id = 3 & page = 2 & display = 10 puis:
getVars['id'] = 3;
getVars['page'] = 2;
getVars['display'] = 10;
devrait-il pas: 'var getVars = [] ' – slebetman
Vous avez raison. Je vous remercie – jsnfwlr