SORU
27 Mart 2009, Cuma


Nasıl Javascript Çağırmak İçin Bir Bağlantı Kullanmak İçin?

Nasıl Javascript Çağırmak İçin Bir Bağlantı Kullanmak İçin?

CEVAP
27 Mart 2009, Cuma


Göze batmayan JavaScript, kütüphane bağımlılık:

<html>
<head>
    <script type="text/javascript">

        // Wait for the page to load first
        window.onload = function() {

          //Get a reference to the link on the page
          // with an id of "mylink"
          var a = document.getElementById("mylink");

          //Set code to run when the link is clicked
          // by assigning a function to "onclick"
          a.onclick = function() {

            // Your code here...

            //If you don't want the link to actually 
            // redirect the browser to another page,
            // "google.com" in our example here, then
            // return false at the end of this block.
            // Note that this also prevents event bubbling,
            // which is probably what we want here, but won't 
            // always be the case.
            return false;
          }
        }
    </script>
</head>
<body>
    <a id="mylink" href="http://www.google.com">linky</a>        
</body>
</html>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • placeboing

    placeboing

    7 Mart 2006
  • xdadevelopers

    xdadeveloper

    25 Aralık 2009
  • Yanko Kral

    Yanko Kral

    8 HAZİRAN 2006