Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 866 | Replies: 9
![]() |
•
•
•
•
| |
•
•
Join Date: Oct 2007
Posts: 63
Reputation:
Rep Power: 0
Solved Threads: 0
I was just wondering if there is anyway to do an AREA SHAPE COORDS with an onClick without using an image. For instance, I want to basically be able to click on the page somewhere (not on an image) and be able to do an onClick. Is this possible at all? If I just had a page with a plain colored background and nothing else on it, could I designate some area on that page using coordinates to perform an onClick?
•
•
Join Date: Apr 2005
Location: New York state
Posts: 498
Reputation:
Rep Power: 5
Solved Threads: 75
Have an empty div with an online attribute ie.,
With that, if someone clicks anywhere in that 100x100 box 50 pixels from the left edge they will go to Google.
html Syntax (Toggle Plain Text)
<div style='height:100px;width:100px;position:absolute;top:0px;left:50px;z-index:9' onclick='window.location="www.google.com";'> </div>
With that, if someone clicks anywhere in that 100x100 box 50 pixels from the left edge they will go to Google.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h-->++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h-->++ r z+*
•
•
Join Date: Apr 2005
Location: New York state
Posts: 498
Reputation:
Rep Power: 5
Solved Threads: 75
•
•
Join Date: Oct 2007
Posts: 63
Reputation:
Rep Power: 0
Solved Threads: 0
Ok so here is the code I am using and all I am getting is a blank page.
<html> <body> <div style="border-color:#000000; background-color:#000000; height:100px; width:100px; position:absolute; top:0px; left:50px; z-index:9" onclick='window.location="www.google.com";'> </div> </body> </html>
•
•
Join Date: Apr 2005
Location: New York state
Posts: 498
Reputation:
Rep Power: 5
Solved Threads: 75
> Ok so here is the code I am using and all I am getting is a blank page.
A few things:
-
- Specifying
A few things:
-
window.location is a host object (browser object); what you probably need to do here is window.location.href = 'url' . Even though the former works, it's an incorrect way of specifying the URI.- Specifying
window.location = 'www.google.com' will make the browser search for a file named 'www.google.com' in the location where you page is located. What you need is window.location.href = 'http://www.google.com/'; I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Oct 2007
Posts: 63
Reputation:
Rep Power: 0
Solved Threads: 0
I got it to work eventually, but it was weird how I got it to work. I eventually just typed some text in to see if it would show up since nothing else was showing up. When I did this, a black box immediately showed up and it worked of course. So then I deleted the text and made it an empty DIV again. This time it worked. I have no idea why, but thanks much for your help.
Now I have another question for you guys. Let's say I want to perform another onclick for a different area on the page, but I want that area to overlap the previous one. So basically I want two active areas, the smaller one sitting on top of the larger one. How might this be done? Thanks
Now I have another question for you guys. Let's say I want to perform another onclick for a different area on the page, but I want that area to overlap the previous one. So basically I want two active areas, the smaller one sitting on top of the larger one. How might this be done? Thanks
Just rinse and repeat.
Plus these questions are more of CSS than of Javascript. Any more queries along the same lines should be directed to the CSS forums.
<html> <body> <div style="border-color:#000000; background-color:#000000; height:100px; width:100px; position:absolute; top:0px; left:50px; z-index:9" onclick='window.location="http://www.yahoo.com/";'> </div> <div style="border-color:#FFF; background-color:#FFF; height:30px; width:30px; position:absolute; top:50px; left:100px; z-index:10" onclick='window.location="http://www.google.com/";'> </div> </body> </html>
Plus these questions are more of CSS than of Javascript. Any more queries along the same lines should be directed to the CSS forums.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Hybrid Mode