Javascript Conditional Logic for Displaying an Image

I have a hardcoded or static image within my web page that I only want to show on the first page of my blog. When the user clicks to page 2, 3, 15, 25 or whatever I do not want the image to display.

The url of the FIRST page is:
/index

The url SECOND and greater pages look like this:
/Default.aspx?PageID=15418397&A=WebApp&CCID=26614&Page=2&Items=15

Image I only want to display on "/index" page:
<div class="fullScale offTag"><img src="/image.jpg" alt="" />
</div>

Open in new window

swaggrKAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
Try
<script>
if (location.href.indexOf("/index")==-1) {
  document.write('<style>div.fullScale.offTag { display:none }</style>'); // add >img if you want to hide ONLY the image
}
</script>

Open in new window

0
 
Rainer JeschorCommented:
Hi,
can you / do you want to use jQuery for this?
Can this be done by clearing the content of that parent DIV ?
Thanks.
0
 
swaggrKAuthor Commented:
Yes, JQuery can be used but I am not sure if clearing the contents of the parent DIV would work or not.
0
 
COBOLdinosaurCommented:
Just don't generate that line of markup when you send pages other than index from the server.

Cd&
0
 
swaggrKAuthor Commented:
@COBOLdinosaur its not that simple. I don't really have control over the server side programming code but I can manipulate the styling, images, divs, etc. using jquery or javascript.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.