Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filtering with jscript

Status
Not open for further replies.

Twenty7

Programmer
May 13, 2002
9
0
0
US
Ok, I've made a dynamic html frame definition page, and I have the pages that are displayed in the main window of the frameset check to see if they are being viewed with the frameset or not, and if they are not, to send the user to the dynamic frame definition page with the url they came from as a variable in the url. It works fine, except when the url they came from has a variable in itself.

for example
if they goto the page 'help.html' without the frameset loaded around the page, it redirects them to 'frameset.html?page=help.html' (that works perfect)
but, when they are viewing the page 'script.pl?action=login' without the frameset loaded around the page, it redirects them to 'frameset.html?page=script.pl?action=login'

Because a url can only contain one ? mark to denote variables, this causes everything after the second ? to be discarded. If I can change the ? symbol to an & symbol, I can get it to work perfect. The problem is, I don't know how I would have it filter the ? in a variable to & using javascript. If anyone can help me I'd appreciate it. Thanks alot ;) -Twenty7
 
i need help with this too, can anyone help to filter characters and replace them with something else?
 
it depends on what you want to do. To just replace '?'s with '&' s, do something like sURL = sURL.replace("?","&").[noevil]

I think a preferrable option may be to use the escape() / unescape() functions to encode url paramaters so any question marks/equal signs don't intefere with the URL.

Note: The encodeURIComponent(), decodeURIComponent(), encodeURI() and decodeURI() functions are more specifically related to escaping URL's, however they are only available in JScript 5.5+ (IE 5.5+) and JavaScript 1.5 (Netscape 6.0+). If that is within your range, I would use them instead of escape()/unescape(). check out the following jscript link:
 
Sweet, thanks man, the replace function worked like a charm. Because of the way I have the dynamic frameset page setup, it basically just remakes the url with the variables on the end.
but I may use the encode function for something else.

Thanks again. -Twenty7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top