Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Skillz: How do you take '+' and 'site:' out of URL string
Old 09-07-2007, 05:08 PM Skillz: How do you take '+' and 'site:' out of URL string
Junior Talker

Posts: 1
Trades: 0
I am trying to use the following function to parse URL strings that look like this:
search4.asp?query=hello+world&site=mysite.web.com

I want to be able to just take out the search terms hello and world

Please take a look at the following code and see why it isn't taking out the '+'
and the 'site=mysite.web.com'


<script type="text/javascript">
function URL2Query()
{
var s = document.referrer;
var query = s.substring(s.indexOf("?")+1,s.length);
var Q = query.split("&");
var hash = {};
for(var i=Q.length-1;i>=0;--i)
{
var q = Q[i].split("=");
if(q[0]) hash[q[0]]=unescape(q[1]);
}
Celeste! is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-07-2007, 07:34 PM Re: Skillz: How do you take '+' and 'site:' out of URL string
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Looks like you know javascirpt better than I do. So I'll just tell you the pseudo code.

Use string.split to turn things into an array, and you might have to almost be recursive about it. Like you're already splitting on & and then =, so within the value part of the = split results you might want to try doing a third split on the + character.

Or, you could just use string.replace to turn "+" into a space, or an empty string ,or whatever it is you want.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 09-08-2007, 12:31 AM Re: Skillz: How do you take '+' and 'site:' out of URL string
Novice Talker

Posts: 13
Name: Ham
Location: Singapore
Trades: 0
try i-- instead of --i? not very sure
__________________
HAFIOŠ Networks -
Please login or register to view this content. Registration is FREE

Exclusive webhosting services
hafio is offline
Reply With Quote
View Public Profile Visit hafio's homepage!
 
Reply     « Reply to Skillz: How do you take '+' and 'site:' out of URL string
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17793 seconds with 12 queries