Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

showing and hiding sections of html based on the url

Status
Not open for further replies.

homeguard

IS-IT--Management
Jul 12, 2007
47
0
0
US
I need to show / hide sections of html code on my page based on what the url says, has anyone done anything like this?
 
With client-side Javascript, sure, but it's much better to do this with server-side scripting.

Lee
 
well this is on a sharepoint site and i dont really have access to the server infos at all, do you happen to have an example of what that code might look like?
 
You'd need to parse the URL. You can access it by using something like:

Code:
var theUrl = window.location;

Then once you've parsed it, you can show / hide sections of content using CSS. Of course, you need a way to access the elements. Let's assume you wanted to hide a DIV element with an ID of "wibble". You would use:

Code:
document.getElementById('wibble').style.display = 'none';

To show it again, you would use:

Code:
document.getElementById('wibble').style.display = 'block';

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top