Re: [jQuery] Using JQuery to manipulate href (URL params)
On 12/12/06, Robert James [EMAIL PROTECTED] wrote: 2. How do I use JQuery to manipulate hrefs? there are a number of security locks on modern browsers that don't allow dynamic manipulation of href. I haven't looked at your example in detail so I am not sure you will run into it, but a lot of basic code that would work with even 4.0 browsers no longer work to avoid spoofing attackes etc. This includes changing the href and status text dynamically. So be warned about odd behavior, with dom and href's. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Using JQuery to manipulate href (URL params)
I'd like to use JQuery to hook up a check box to flip a URL param in a bunch of hrefs. The href would either be 'http://myapp/do/this?id=3sendAlert=1' or http://myapp/do/this?id=3sendAlert=0' Something like: $('#sendAlert').change(function() { sendAlert = (this.checked ? '1' : '0') ; $('#panel a').href.removeTheSendAlert - not sure how to do this $('#panel a').href.append('sendAlert=' + sendAlert); The two problems I'm having are: 1. What is the code to remove the old param of sendAlert (you can assume that it's at the end)? 2. How do I use JQuery to manipulate hrefs? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Using JQuery to manipulate href (URL params)
// there are rumblings of romoving the event shortcuts (eg $().change) // not sure if change works on a checkbox, if not click should work $('#sendAlert').bind(change,function(){ // find all links in #panel and apply a function to each one $(#panel a).each(function(){ // within each 'this' refers to the element object // not sure if the regex is right this.href=this.href.replace(/sendAlert=[\d]+/,sendAlert=+( this.checked?1:0)); }); }); Blair On 12/13/06, Robert James [EMAIL PROTECTED] wrote: I'd like to use JQuery to hook up a check box to flip a URL param in a bunch of hrefs. The href would either be 'http://myapp/do/this?id=3sendAlert=1' or http://myapp/do/this?id=3sendAlert=0' Something like: $('#sendAlert').change(function() { sendAlert = (this.checked ? '1' : '0') ; $('#panel a').href.removeTheSendAlert - not sure how to do this $('#panel a').href.append('sendAlert=' + sendAlert); The two problems I'm having are: 1. What is the code to remove the old param of sendAlert (you can assume that it's at the end)? 2. How do I use JQuery to manipulate hrefs? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/