BrightNail
11-11-2004, 12:12 AM
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?
var str = 'www.somesite.com/index.html?hello';
var pat = /\?.*$/;
var url = str.replace(pat,''));
BrightNail
11-11-2004, 01:03 AM
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.
apparently I misinterpreted or maybe I still don't understand.
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();
BrightNail
11-11-2004, 02:08 AM
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?
you would need to refresh the page to make sure it is stripped off..