Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 21:06

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[H]Div mit onClick und enthaltenem Link sollen onClick nicht ausführen

Discussion on [H]Div mit onClick und enthaltenem Link sollen onClick nicht ausführen within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2012
Posts: 19
Received Thanks: 16
[H]Div mit onClick und enthaltenem Link sollen onClick nicht ausführen

Hallo Leute,

Ich hab ein Problem.
Mein Code:

HTML Code:
<div onclick="weiterleitung"><a href="www.">Link</a></div>
Ich möchte, wenn man auf den Link klickt, soll das "onclick" in dem div nicht ausgeführt werden.

LG xmaster
xmaster© is offline  
Thanks
1 User
Old 08/16/2012, 18:04   #2
 
elite*gold: 0
Join Date: Sep 2010
Posts: 17
Received Thanks: 3
Dann leosche es raus! Auserdem fehlen die klammern onClick="weiterleitung()" daher duerfte sowieso nix passieren....
FR28 is offline  
Thanks
1 User
Old 08/16/2012, 18:57   #3
 
devcode's Avatar
 
elite*gold: 10
Join Date: Feb 2012
Posts: 313
Received Thanks: 61
oh man
devcode is offline  
Old 08/17/2012, 06:51   #4
 
elite*gold: 0
Join Date: Oct 2008
Posts: 319
Received Thanks: 88
Versuch so etwas in der Art.
PHP Code:
var onclickListener = function (e) {
  if (
e.target === this.getElementsByTagName('a')[0]) 
  return 
false;
}; 
Dein Event wird abgefeuert egal ob man auf den Link klickt oder auf das DIV Element,
e.target ist das Element das tatsächlich angesprochen wurde (in deinem Fall der Link).
Falls this.get[...] nicht klappt kannst du das auch durch e.relatedTarget ersetzen, ist
aber nicht crossbrowserfähig. Auserdem solltest du Events im Script binden und nicht
direkt im HTML, das ist aber mehr so ne Übersichtlichkeitssache.
Fratyr is offline  
Old 08/17/2012, 20:17   #5
 
elite*gold: 0
Join Date: Sep 2010
Posts: 17
Received Thanks: 3
Code:
<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>
  </head>
  <body>
    <div class="box">
      <a href="#1" >Link</a>
      <a href="#2" >Link</a>
    </div>
  </body>
</html>


<script type="text/javascript">
  
  $('.box').click(function(event){
    $target = $(event.target);
    if($target.is('.box')) {
      alert("box geklickt");
      weiterleitung();
    }
  });
  
  function weiterleitung(){}

</script>
FR28 is offline  
Reply


Similar Threads Similar Threads
[Notice] Post a virus scan link before posting a file link
04/19/2011 - Grand Chase Hacks, Bots, Cheats & Exploits - 23 Replies
This is .Yuzuru reminding you all to be reminded before downloading such programs or files in the section you're viewing on hacks... Reminders 1. Check if the user is on the trusted list or not 2. Check the virus scan's result 3. Update your anti-virus program 4. Check the other members' comments 5. Check if the thread is confirmed 6. Check the link if it really was a download link. 7. Check if GCI members has confirmed that the thread is safe for using it.



All times are GMT +2. The time now is 21:06.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.