Results 1 to 3 of 3

Thread: a beter way for url vars?

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    5

    Default a beter way for url vars?

    Hi,

    I am looking for a better way to get url parameters. Here's what I have so far

    Code:
    ,viewQuestions: function(btn,e) {
            
            var url = window.location.href;
            var args = url.split('?');
            var urlVars = Ext.urlDecode(args[1]);
            location.href = '?a='+urlVars.a+'&id='+this.menu.record.id;
            
        }
    Maybe there is a faster and easier way to do this.

    Thank you

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    I would use:
    Code:
    var args = location.search.substr(1),
        params = Ext.urlDecode(args),
        newParams = {
            a: params.a,
            id: this.menu.record.id
        };
    location.search = '?' + Ext.urlEncode(newParams);
    Last edited by Condor; 24 Feb 2011 at 11:31 PM. Reason: Fixed ;

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    5

    Default

    Thank you

    I ended up with this (a ; was needed before second location.search)

    Code:
    var args = location.search.substr(1),
                params = Ext.urlDecode(args),
                newParams = {a: params.a, id: this.menu.record.id};
            location.search = '?' + Ext.urlEncode(newParams);

Similar Threads

  1. [FIXED][3.1] Global vars
    By Condor in forum Ext 3.x: Bugs
    Replies: 4
    Last Post: 14 Jan 2010, 6:20 AM
  2. how can i get session vars (into) a js script
    By diego_83 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 9 Apr 2008, 10:12 AM
  3. Replies: 0
    Last Post: 26 Oct 2007, 8:07 AM
  4. Get the vars in query string the right way??
    By alietss in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 30 Aug 2007, 1:25 PM
  5. can initPaging use form vars?
    By ryddler in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 28 Feb 2007, 3:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •