Solved

Making my page's Background Image clickable. Is this possible?

Posted on 2008-06-10
5
869 Views
Last Modified: 2008-09-20
I want my HTML page to have a tiled background Image, which if clicked redirects to some set link in the Javascript.

However, I also want a content block that is above the background, that is not clickable, since if the user clicked in this content box, they wouldn't be clicking on the bkg image.

Any ideas on how to achieve this?

Thanks
0
Comment
Question by:nverfollowtt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21758975
Try Here
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title></title>
  </head>
  <body onload="window.backgroundClick=true" 
  onclick="if (window.backgroundClick) location='http://google.com/search?q=background'" 
  style="background-color:green">
<div 
onmouseover="window.backgroundClick=false"
onmouseout="window.backgroundClick=true"
onclick="location='http://google.com/search?q=div'" 
 style="position:absolute; width:200px; height:200px; background-color:red">Hello</div>
  </body>
</html>

Open in new window

0
 

Author Comment

by:nverfollowtt
ID: 21760058
Hey mplungjan that is all inline controls, any way to do this with strickly a JS include?
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 21760754
Just take what's in the window.onload snippet here:
<html>
  <head>
  <title></title>
<script>
window.backgroundClick=true;
window.onload=function() {
  document.getElementById('centerPiece').onclick=function() { location='http://google.com/search?q=div' }
  document.getElementById('centerPiece').onmouseover=function() { window.backgroundClick=false }
  document.getElementById('centerPiece').onmouseout=function() { window.backgroundClick=true }
  document.onclick=function() {
    if (window.backgroundClick) location='http://google.com/search?q=background';
  }
}
</script>
  </head>
  <body style="background-color:green">
<div id="centerPiece" style="position:absolute; width:200px; height:200px; background-color:red">Hello</div>
  </body>
</html>

Open in new window

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question