Current location: Hot Scripts Forums » General Web Coding » JavaScript » disable / enable onclick


disable / enable onclick

Reply
  #1 (permalink)  
Old 03-02-09, 04:02 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
disable / enable onclick

Hi there..

I have a <div> with a "onclick" link attached to is like this:

HTML Code:
<div id="content" style="background:url(images/home/home.jpg) top center no-repeat; cursor:pointer;" onclick="window.location='details.php'">
now I want to disable this link in a javascript function..
think it should be somthing like this.. but don't know what's wrong with it:

Code:
document.getElementById("content").onClick = 'window.open("#")';
who can help me out here..

_j
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-02-09, 08:10 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Code:
document.getElementById("content").onclick = function() {}
...this should do it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-02-09, 08:11 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
okay.. i'll give it a try..

and then place the window.open in the function?.. and there disable an enable it?.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-02-09, 09:43 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
Nope,

Just use the empty function as Nico suggested. Nothing goes in there

Code:
onclick = function() { nothing here };
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-02-09, 09:44 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
okay...

and to enable it again?..
the line of code I post above?.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-02-09, 09:49 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
It is easiest to add events through functions, so yea just attach through the same way again:

Code:
onclick = function() { window.location='details.php'; };
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP adding disable and enable buttons pablo1999 PHP 3 03-23-07 07:37 PM
Onclick event of a button not working phathutshedzo ASP.NET 4 12-06-06 06:28 AM
how to use onclick in php coolcoder HTML/XHTML/XML 2 05-31-06 01:40 PM
Enable a disabled PHP function - Need a little help steveo PHP 0 02-11-06 01:01 PM
Some Onclick event help. Killswitch JavaScript 0 07-07-05 05:44 PM


All times are GMT -5. The time now is 07:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.