View Full Version : Pass parameters through URL

12-01-2008, 01:22 AM
Ok, so I recently redid my site, so there are multiple pages on one.

You can see an example of this here:


Just press the tabs and you'll see what I mean.

But I do have other pages that link back to, for example, the "board maintenance" tab, but it's still on the guides.html page.

And the content for it is contained in a div, so I want this sort of thing, but translated into a URL if it's possible:


Is this possible? maybe not even this, but something that has the same effect. I hope it can be done, since I really want to have content put in tabs like this, where the page doesn't change.

Thanks very much for any help given,


12-01-2008, 04:46 AM
In your approach I think two JS functions are using for hiding/showing the tabs; one for hiding all the tab content div element and another one for showing the needed div element.

I think you can use the following function and associate this function and pass the element id which clicked. Maintain an element ID array inside the function through which you can display and hide the div element. The logic is to display the div element whose ID passed into the function rest of the elements will be hidden.

function displayTheClickedTab(clickedId){
var tabContentId = ['intro','maintenance','ridetips','tricktips']; //Enter the element ids which is the container of the tabs like the mentioned ones.
document.getElementById(clickedId).style.display = 'block';

for(var i = 0; i < tabContentId.length; i++){
if(tabContentId[i] !== clickedId){
document.getElementById(tabContentId[i]).style.display = 'none';

Hope this helps

12-01-2008, 08:56 AM
Yea, thanks very much for that - helps condense the code into one function which will definitely save time and space, I knew it could be done but I'm not really experienced enough at JavaScript to know how to do it.

Anyway, maybe this makes it easier to pass that function through a URL?

12-01-2008, 08:56 AM

(v 2.2) A link from another page linking to the target page can select a tab on the later when loaded, via the URL parameter string ((ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0).

12-01-2008, 09:04 AM
Thanks for that, but I'm still not sure how I would do it on my page, the code on that page seems very complicated, any way I could condense it down without having to copy a load off of that script?

Would it be something like: www.bombthehills.com/guides.html?displayTab=1


12-01-2008, 09:12 AM
You could write your own code to snag the query string from the URL and to then do something with it. But that seems about as complicated, if not more so, as using the script I suggest. With the Dynamic Drive script, all you have to do is follow the instructions.

12-01-2008, 12:53 PM
Yea, thanks for that, I've implemented the new tab code, but still having problems - follow on thread here: http://www.dynamicdrive.com/forums/showthread.php?t=39276

Edit: How has this got over 3000 views in a day? :S, bot?