AndrewM16921 Posted January 16, 2009 Share Posted January 16, 2009 I have URLs that look something like this: http://site.com/phpBB3/viewforum.php?f=15 http://site.com/phpBB3/viewtopic.php?f=15&t=128 In the forum's Overall_Header.html I have a portion of HTML that I want displayed in all sections except for one, which is f=15. So, what I wanted to do what something like this: if(f!=15) { ... } But, i don't know how to grab the value of f from the URL to use in a script. So.. How can I? Quote Link to comment Share on other sites More sharing options...
corbin Posted January 16, 2009 Share Posted January 16, 2009 You could use document.URL and indexOf and some other functions to manipulate it out. indexOf and substring should be good enough..... var url = document.URL; var start = url.indexOf('f='); var f; if(start >= 0) { var end = url.indexOf('&'); if(end < 0) end = url.length(); url.substring(url.indexOf('f='), end); } That should work. Quote Link to comment Share on other sites More sharing options...
abdfahim Posted January 16, 2009 Share Posted January 16, 2009 as the example links u r providing is php page, i assume u have php supported server. Then do u mind if u use a lil bit of php coding? If not, then u can use the following <SCRIPT language="javascript"> function myfunction(){ var f='<?php echo $_GET['f'];?>'; } </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.