jQuery to identify URL and append parameters

This jQuery code will run as a bookmarklet in the wordpress editor. The bookmarklet / jQuery code will edit the text in the content field and append a parameter (ex. ?parameter) to the end of the URL.

The URL is always the same domain name (ex. domain.com). However the URL will often contain directories (ex. domain.com/directory/index.html?parameter). I need the jQuery code to append regardless of what is after the domain name.

The most complex situation would be

domain.com/directory/index.html?someotherparameter?parameter

. This content area will often contain more than one url so the script will need to loop through the entire text.

Your example code was doing exactly what you asked it to. It replaced the 'domain.com' portion of the the string with the domain and your parameters. Once it found 'domain.com' it stopped looking to see if there was anything else attached to it.