homepage Welcome to WebmasterWorld Guest from 54.197.130.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Javascript If/Then.
based on URL
mcjohnson




msg:4080774
 8:52 pm on Feb 15, 2010 (gmt 0)

i have a simple HTML site that I am trying to hide an element (an H1) tag for a specific page. It's a templated system so the pages are created on the fly but output as HTML.

What I want is to hide the H1 element if the particular page is "Stormwater-District.html".

Possible?

 

birdbrain




msg:4080783
 9:14 pm on Feb 15, 2010 (gmt 0)

Hi there mcjohnson,

here is a possible solution...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title></title>

<script type="text/javascript">

function removeHeader(){

n=location.href.split('/');

if(n[n.length-1]=='Stormwater-District.html'){
document.getElementsByTagName('h1')[0].style.display='none';
}
}

if(window.addEventListener){
window.addEventListener('load',removeHeader,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',removeHeader);
}
}
</script>

</head>
<body>

<h1>this is h1 </h1>

</body>
</html>

birdbrain

mcjohnson




msg:4080900
 12:18 am on Feb 16, 2010 (gmt 0)

AWESOME! That worked!

Thank you birdbrain!

birdbrain




msg:4081101
 7:28 am on Feb 16, 2010 (gmt 0)

No problem, you're very welcome. ;)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved