JAVASCRIPT DOCUMENT NESNESİ
anchors[] : HTML doküman üzerinde name ve/veya id özellikleri tanımlanmış anchor elementlerinin listesini verir.
characterSet : HTML dokümanın ISO-8859-9 veya UTF-8 gibi karakter setini verir.
contentType : HTML dokümanın HTTP başlığındaki MIME tipini belirten Content-Type değerini verir.
cookie : Çerezler başlığında anlatılmıştır.
domain : HTML dokümanın alan adını verir.
forms[] : HTML doküman üzerindeki formlar hakkında bilgi verir.
images[] : HTML doküman üzerindeki resimler hakkında bilgi verir.
height : HTML dokümanın body yüksekliğini verir.
lastModified : HTML dokümanın son değiştirilme tarihini verir.
links[] : HTML doküman üzerindeki linkler hakkında bilgi verir.
referer : Mevcut sayfaya hangi sayfadan gelindiği bilgisini verir.
title : HTML dokümanın sayfa başlığını verir.
URL : HTML dokümanın adres çubuğundaki linki verilir.
width : HTML dokümanın body genişliğini verir.
Metod : Açıklama
getElementById ( ) : Verilen id numarasına göre ilgili nesneye ve özelliklerine ulaşılır.
getElementsByName( ) : Verilen name özelliğine göre ilgili nesneye ve özelliklerine ulaşılır.
getElementsByTagName() : HTML doküman üzerinde belirtilen etiket ismine ait bütün elementlerin bir listesini verir.
createElement() : Herhangi bift HTML elementinin oluşturulmasını sağlar.
createTextNode() : Yeni bir metin düğümü (text_node) oluşturulmasını sağlar.
write(),writeln() : HTML dokümana verilen içeriğin yazılmasını sağlar.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// <script type="text/javascript" language="javascript"> document.write("characterSet :"+document.characterSet+"<br>"); document.write("contentType :"+document.contentType+"<br>"); document.write("domain :"+document.domain+"<BR>"); document.write("title :"+document.title+"<br>"); document.write("referrer :"+document.referrer+"<br>"); document.write("URL :"+document.URL+"<BR>"); document.write("width :"+document.width+"<br>"); document.write("height :"+document.height+"<br>"); document.write("lastModified :"+document.lastModified+"<br>"); </script> |
1 2 3 4 5 6 7 8 9 10 |
<a href="https://www.caglarbostanci.com.tr">Çağlar BOSTANCI</a><BR> <a href="https:/www.google.com.tr">GOOGLE</a><BR> <a href="http://www.yandex.com.tr">YANDEX</a><BR> <img src="" alt="resim" title="Çağlar BOSTANCI"><BR> <form name="form1"> </form> |
1 2 3 4 5 6 7 |
<script type="text/javascript" language="javascript"> document.write("images :"+document.images.length+"<br>"); document.write("forms :"+document.forms.length+"<br>"); document.write("links :"+document.links.length+"<br>"); </script> |
getElementById KULLANIMI
1 2 3 4 5 6 7 8 9 |
<input type="text" id="butonadi" name="btnname"> <button name="buton" id="buton" onClick="dgtr();">BUTON ADINI DEĞİŞTİR</button> <script type="text/javascript" language="javascript"> function dgtr(){ document.getElementById('buton').innerHTML=document.getElementById('butonadi').value; } </script> |
getElemenByName KULLANIMI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<input name="form2" id="merhaba1" type="text" name="text"> <input name="form2" id="merhaba2" type="text" name="text"> <input name="form2" id="merhaba3" type="text" name="text"> <button onClick="nes('form2')" >Nesne Listele</button> <script type="text/javascript" language="javascript"> function nes(nesne_adi){ var nesne=new Array(); nesne=document.getElementsByName(nesne_adi); alert("ELEMAN SAYISI :"+nesne.length+"<BR>"); for(var i=0;i<nesne.length;i++){ var elemanlar=document.getElementsByName(nesne_adi).item(i); document.write("eleman id:"+i+" :"+elemanlar.id+" ELEMAN VALUE"+elemanlar.value); } } </script> |
getElementsByTagName KULLANIMI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<p>Butona tıklayınca buradaki metin style değişecek</p> <button onClick="degistir()">DEĞİŞTİR</button> <button onClick="gerial()">GERİAL</button> <script type="text/javascript" language="javascript"> var tag=document.getElementsByTagName('p'); document.write("TOPLAM ELEMENT SAYISI"+tag.length+"<BR>"); document.write(tag[0].id); function degistir(){ tag[0].style.fontWeight="bold"; tag[0].style.fontFamily="arial"; tag[0].style.color="green"; } function gerial(){ tag[0].style.fontWeight="none"; tag[0].style.fontFamily=""; tag[0].style.color=""; } </script> |
createElement() KULLANIMI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<div id="formalani">>></div> <div id="sif">>></div> <div id="ybut">>></div> <button onClick="formedit()">FORMU OLUŞTUR.</button> <script type="text/javascript" language="javascript"> function formedit(){ var txt=document.createElement('input'); txt.value="ÇAĞLAR BOSTANCI";txt.name="username"; document.getElementById('formalani').appendChild(txt); var sifre=document.createElement('input'); sifre.name="sifre2"; sifre.value="sifre1"; sifre.type="password"; document.getElementById('sif').appendChild(sifre); var addbuton=document.createElement('button'); addbuton.value="dddd"; addbuton.name="yenibuton"; addbuton.innerHTML="YENİ BUTON"; document.getElementById('ybut').appendChild(addbuton); } </script> |
createTextNode() KULLANIMI
1 2 3 4 5 6 7 8 9 10 11 |
<div id="textnode"></div> <button onClick="yenimetialani()">TextNode Kullanımı</button> <script type="text/javascript" language="javascript"> function yenimetialani(){ var yenitextalani=document.createElement('div'); yenitextalani=document.createTextNode("MERHABA DÜNYA"); document.getElementById('textnode').appendChild(yenitextalani); } </script> |