Forum Moderators: open
Looking at:
http://example.com?a=123&b=456&c=789#111
I am trying to get vale for "c" and everything behind it, ie c=789#111 .
using document.write(window.location.search)
produces everything but #111 (and I really want that part as well)
Any help is greatly appriciated
I did try using indexOf('#') but it didn't work, and that is what I want.
Following script looks at search string, and returns value of target parameter (in the example below that would be ' q ') and then exits. It could be easily modified to return all search parameters.
<script type="text/javascript">
function get_search_string()
{
var fullurl=window.location.search
var param=(fullurl.slice(1))var pairs = param.split("&")
var targetvar = "q"for(var i = 0; i < pairs.length; i++)
{
var pos = pairs[i].indexOf('=')
if (pos == -1) continue
var argname = pairs[i].substring(0,pos)
var value = pairs[i].substring(pos+1)
if (argname == targetvar)
{
var searchstring = value
{break}
}
}return searchstring
}