Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Is there a way to dynamically alter the URL string w/o refreshing or redirecting page

    lets say I have this.


    www.somesite.com/index.html?hello

    is there a way that I can strip the "?hello" without refreshing/redirecting the page.

    I have a frameset that reads a parameter for the url string. Unfortunetly, because it is a frameset...when I use the navigation, that appended URL ?hello is in the address box even when I go to other pages...

    BUT I have code that 'reads' that url string...but I want to erase that last bit.

    can this be done?

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var str = 'www.somesite.com/index.html?hello';
    var pat = /\?.*$/;
    var url = str.replace(pat,''));

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks...but, it didn't seem to work. that ?hello is still in the search string.

    this is what i have:

    function switchframe()
    {
    var pageArrays = new Array('index.html','hello.html','cars.html');
    var thisurl = top.location.search.substring(1);
    if(thisurl){
    var str = top.location;
    var pat = /\?.*$/;
    var url = str.replace(pat,'');
    parent.content.location.href = pageArrays[thisurl];
    }
    }
    switchframe();

    as you can see.....I read the url string...and I pass a number ..ala..

    www.somesite.com/index.html?1

    --and after I read that '1', so I know which array position I want - I then want to get rid of that "?1"...........but it doesn't seem to work..its still there in the URL string.

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    apparently I misinterpreted or maybe I still don't understand.

    Code:
    function switchframe()
    {
        var thisurl = top.location.search.substring(1);
        if(thisurl){
            var str = top.location;
            var pat = /^.*\?/;
            var url = str.replace(pat,'');
            parent.content.location.href = 'http://www.yoursite.com/' + url + '.html';
        }
    }
    switchframe();

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts
    basically....I have the capturing of the string working...the thing is I want the url to

    go from:

    http://www.somesite.com/index.html?1

    to

    http://www.somesite.com/index.html

    without having to reload or refresh the page.

    because the site is in a frameset..even when I switch pages within a frame, that URL is still in the addrss box as: http://www.somesite.com/index.html?1

    basically, is there a way to remove that part of the URL string dynamically?

  • #6
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you would need to refresh the page to make sure it is stripped off..


  •  

    Posting Permissions

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