Closed Thread Icon

Topic awaiting preservation: XSSI Query to JavaScript (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25106" title="Pages that link to Topic awaiting preservation: XSSI Query to JavaScript (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: XSSI Query to JavaScript <span class="small">(Page 1 of 1)</span>\

 
Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 02-25-2005 01:41

I currently use XSSI in a client's site to parse a simple query string sent from one page to another.

To clarify, Page A has a link like so: <a href="page_b.shtml?08">Link</a>

Page B parses the query string with <!--#set var="which" value="$query_string_unescaped" --> which is then echoed where appropriate with <!--#echo var='which' -->.

I'm currently creating a CD-ROM version of their site, which they want to pass out at shows, and I need to convert this XSSI function to JavaScript so it will work client-side. I've uncovered a couple of scripts for parsing query strings, but are far more complicated than I need.

I believe I remember how to parse the URL from X position to Y position, but how do I just look for the ? and parse everything after that? If I can figure that much out, I think I can do the rest.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 02-25-2005 02:10

breaking it down..

url = www.something.com?555

start = url.lastIndexOf("?") + 1; // Start after the ?

end = url.length // (well the end.)

stuff = url.substring( start, end );



.:[ Never resist a perfect moment ]:.

BillyRayPreachersSon
Bipolar (III) Inmate

From: London
Insane since: Jul 2004

posted posted 02-25-2005 10:23

I had someone ask me the same question yesterday:

code:
var newStr = oldStr.substr(oldStr.indexOf('?') + 1);



Personally, I would avoid all use of substring, as I read in several reputable places that it was to be deprecated. Of course, this could be complete tosh, but you just never know!

Dan

(Edited by BillyRayPreachersSon on 02-25-2005 10:25)

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 02-25-2005 20:20

Ah, excellent.

Was confused why I kept getting "undefined" there for a while, then realized I forgot to define var url = unescape(document.location.href). :P

Works now! Thanks!

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 02-25-2005 20:23

Is substring deprecated?

I thought they were two similar but different functions.



.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu