User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 330,091 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,259 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 325 | Replies: 9
Reply
Join Date: Oct 2007
Posts: 52
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is online now Online
Junior Poster in Training

onClick question

  #1  
11 Days Ago
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 403
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 55
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: onClick question

  #2  
10 Days Ago
Have an empty div with an online attribute ie.,
  1. <div style='height:100px;width:100px;position:absolute;top:0px;left:50px;z-index:9' onclick='window.location="www.google.com";'>
  2. </div>

With that, if someone clicks anywhere in that 100x100 box 50 pixels from the left edge they will go to Google.
Quote by AncientDragon:
Requests for help via PM will just be ignored. Post your questions in one of the technical boards and you will get an answer from someone.
And I WILL NOT DO YOUR HOMEWORK!
Reply With Quote  
Join Date: Oct 2007
Posts: 52
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is online now Online
Junior Poster in Training

Re: onClick question

  #3  
10 Days Ago
Thanks a bunch! That is exactly what I was looking for.
Reply With Quote  
Join Date: Oct 2007
Posts: 52
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is online now Online
Junior Poster in Training

Re: onClick question

  #4  
10 Days Ago
Ok so it's me again. It did not end up working for some reason. I tried to just use the code you show above as a test with a blank page and it isn't working. Do you have any idea why this might be?
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 403
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 55
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: onClick question

  #5  
10 Days Ago
give the <div> tag a black border and background just so you can see where it is for testing purposes, you might be misclicking
Quote by AncientDragon:
Requests for help via PM will just be ignored. Post your questions in one of the technical boards and you will get an answer from someone.
And I WILL NOT DO YOUR HOMEWORK!
Reply With Quote  
Join Date: Oct 2007
Posts: 52
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is online now Online
Junior Poster in Training

Re: onClick question

  #6  
10 Days Ago
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>
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 403
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 55
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: onClick question

  #7  
10 Days Ago
Not sure, just tested it and it works fine works.
Quote by AncientDragon:
Requests for help via PM will just be ignored. Post your questions in one of the technical boards and you will get an answer from someone.
And I WILL NOT DO YOUR HOMEWORK!
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,610
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 21
Solved Threads: 297
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: onClick question

  #8  
10 Days Ago
> Ok so here is the code I am using and all I am getting is a blank page.

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."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Oct 2007
Posts: 52
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is online now Online
Junior Poster in Training

Re: onClick question

  #9  
10 Days Ago
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
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,610
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 21
Solved Threads: 297
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: onClick question

  #10  
9 Days Ago
Just rinse and repeat.
<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."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Marketplace (Sponsored Links)
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC