Şimdi Ara

javascript dosyası çağırma

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
13
Cevap
0
Favori
4.464
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • nette js komutlarını kolayca bulabiliyoruz ve bunu bir hmtl dosyasına yapıştırarak çalıştırabiliyoruz..
    aşağıdaki gibi bir menü örneği var. bu menü her sayfanın başında sabit duracak. bunu html de çalıştırabiliyorum.. fakat web sayfası onlarca sayfadan oluşuyor ve ben bu kodları her sayfaya yapıştırmak yerine (üzerinde değişiklik yaptığımda örneğin buton eklemek istediğimde her sayfayı ayrı ayrı açıp kodlar üzerinde değişklik yapmam gerekeceğinden ) ben bu komutları JS dosyasına atıp her sayfadan JS dosyasını çağırmak istiyorum..

    JS ve HTML içine yazılacak kodları nasıl yapabilirim.. teşekkürler..

    <script type="text/javascript">
    /* This script and many more are available free online at
    The JavaScript Source!!http://javascript.internet.com
    Created by: Konstantin Jagello |http://javascript-array.com/ */
    var TimeOut = 300;
    var currentLayer = null;
    var currentitem = null;
    var currentLayerNum = 0;
    var noClose = 0;
    var closeTimer = null;

    function mopen(n) {
    var l = document.getElementById("menu"+n);
    var mm = document.getElementById("mmenu"+n);

    if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
    currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;
    } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
    }
    }

    function mclosetime() {
    closeTimer = window.setTimeout(mclose, TimeOut);
    }

    function mcancelclosetime() {
    if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
    }
    }

    function mclose() {
    if(currentLayer && noClose!=1) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
    } else {
    noClose = 0;
    }
    currentLayer = null;
    currentitem = null;
    }

    document.onclick = mclose;
    </script>

    <style>
    #dd {
    margin-left: 25%;
    padding: 0 0 20px 0;
    }

    #dd li {
    margin: 0;
    padding: 0;
    list-style: none;
    float: left;
    font: bold 11px arial;
    }

    #dd li a.menu {
    display: block;
    text-align: center;
    background: #5970B2;
    padding: 4px 10px;
    margin: 0 1px 0 0;
    color: #FFF;
    width: 60px;
    text-decoration: none;
    }

    #dd li a.menu:hover {
    background: #49A3FF;
    }

    .submenu {
    background: #EAEBD8;
    border: 1px solid #5970B2;
    visibility: hidden;
    position: absolute;
    z-index: 3;
    }

    .submenu a {
    display: block;
    font: 11px arial;
    text-align: left;
    text-decoration: none;
    padding: 5px;
    color: #2875DE;
    }

    .submenu a:hover {
    background: #49A3FF;
    color: #FFF;
    }
    </style>


    <ul id="dd">
    <li><a href="#" class="menu" id="mmenu1"
    onmouseover="mopen(1);"
    onmouseout="mclosetime();">Home</a>
    <div class="submenu" id="menu1"
    onmouseover="mcancelclosetime()"
    onmouseout="mclosetime();">
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">HTML Tutorials</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">DHTML Tutorials</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">JavaScript Tutorials</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">CSS Tutorials</a>
    </div>
    </li>
    <li><a href="#" class="menu" id="mmenu2"
    onmouseover="mopen(2);"
    onmouseout="mclosetime();">Download</a>
    <div class="submenu" id="menu2"
    onmouseover="mcancelclosetime()"
    onmouseout="mclosetime();">
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">ASP Scripts</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">PHP Scripts</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">Ajax Scripts</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">Perl Scripts</a>
    </div>
    </li>
    <li><a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" class="menu" data-href="#" class="menu">Order</a></li>
    <li><a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" class="menu" data-href="#" class="menu">Help</a></li>
    <li><a href="#" class="menu" id="mmenu3"
    onmouseover="mopen(3);"
    onmouseout="mclosetime();">Contact</a>
    <div class="submenu" id="menu3"
    onmouseover="mcancelclosetime()"
    onmouseout="mclosetime();">
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">Office</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">Sales</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">Customer Service</a>
    <a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=19476624&url=#" data-href="#">Shipping</a>
    </div>
    </li>
    </ul>







  • deniyorum olmuyor:S

    1.js die bi dosya oluşturdum içine burda dendiği gibi şu kodları yapıştırdım




    /* This script and many more are available free online at
    The JavaScript Source!!http://javascript.internet.com
    Created by: Konstantin Jagello |http://javascript-array.com/ */


    var TimeOut = 300;
    var currentLayer = null;
    var currentitem = null;
    var currentLayerNum = 0;
    var noClose = 0;
    var closeTimer = null;

    function mopen(n) {
    var l = document.getElementById("menu"+n);
    var mm = document.getElementById("mmenu"+n);

    if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
    currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;
    } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
    }
    }

    function mclosetime() {
    closeTimer = window.setTimeout(mclose, TimeOut);
    }

    function mcancelclosetime() {
    if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
    }
    }

    function mclose() {
    if(currentLayer && noClose!=1) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
    } else {
    noClose = 0;
    }
    currentLayer = null;
    currentitem = null;
    }

    document.onclick = mclose;




    1.HTM dosyasındada şu kodla çağırıyorum uzun zamandır ama gelmiyor..

    <script language="javascript" type="text/javascript" src="1.js"></script>




    < Bu mesaj bu kişi tarafından değiştirildi deryacom -- 6 Aralık 2007; 10:17:48 >




  • Çalışmaması için:
    1. Ya script hatalıdır.
    2. Ya da scripti başka bir klasöre kaydetmişsindir.

    Script dosyanın tepesine window.alert("deneme"); gibi bir satır yaz. Dosyanın yüklenip yüklenmediğini denemiş olursun.
    Firefox'ta açarsan Araçlar menüsünden Konsol Hatası seçeneğini seçerek sayfada oluşan javascript hatalarını görebilirsin.
  • kodları html içine yapıştırınca çalışıyor..her sayfaya bu kodları yapıştırmak yerine ayrı bi js dosyasında tuttup html içinden çağırmak istiyorum..

    EDİT : window.alert("deneme"); ÇALIŞIYOR...



    < Bu mesaj bu kişi tarafından değiştirildi deryacom -- 6 Aralık 2007; 15:10:19 >
  • bu sorunu çözmüştüm.. buraya yazayım belki lazım olur birilerine ...

    menu.js
    var win = null;
    function NewWindow(mypage,myname,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings =
    'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win = window.open(mypage,myname,settings)
    }

    var TimeOut = 300;
    var currentLayer = null;
    var currentitem = null;
    var currentLayerNum = 0;
    var noClose = 0;
    var closeTimer = null;

    function mopen(n) {
    var l = document.getElementById("menu"+n);
    var mm = document.getElementById("mmenu"+n);

    if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
    currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;
    } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
    }
    }

    function mclosetime() {
    closeTimer = window.setTimeout(mclose, TimeOut);
    }

    function mcancelclosetime() {
    if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
    }
    }

    function mclose() {
    if(currentLayer && noClose!=1) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
    } else {
    noClose = 0;
    }
    currentLayer = null;
    currentitem = null;
    }

    document.onclick = mclose;


    menu_sayfasi_html

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <script language="javascript" type="text/javascript" src="menu.js"></script>
    <LINK href="menu.css" type="text/css" rel="STYLESHEET">


    </HEAD>

    <BODY>
    <UL id=dd>
    <LI><A class=menu id=mmenu1 onmouseover=mopen(1); onmouseout=mclosetime();
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Ana Sayfa</A>
    <DIV class=submenu id=menu1 onmouseover=mcancelclosetime()
    onmouseout=mclosetime();><A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">HTML Tutorials</A>
    <A href="http://www.javascriptindir.com/testet.asp?id=1226#">DHTML
    Tutorials</A> <A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">JavaScript
    Tutorials</A> <A href="http://www.javascriptindir.com/testet.asp?id=1226#">CSS
    Tutorials</A>
    <A href="http://www.javascriptindir.com/testet.asp?id=1226#">BEN EKLEDÝM </A>
    </DIV></LI>
    <LI><A class=menu id=mmenu2 onmouseover=mopen(2); onmouseout=mclosetime();
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Dosya Ýndir</A>
    <DIV class=submenu id=menu2 onmouseover=mcancelclosetime()
    onmouseout=mclosetime();><A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">ASP Scripts</A> <A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">PHP Scripts</A> <A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Ajax Scripts</A> <A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Perl Scripts</A>
    </DIV></LI>
    <LI><A class=menu
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Order</A> </LI>
    <LI><A class=menu
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Help</A> </LI>
    <LI><A class=menu id=mmenu3 onmouseover=mopen(3); onmouseout=mclosetime();
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Contact</A>
    <DIV class=submenu id=menu3 onmouseover=mcancelclosetime()
    onmouseout=mclosetime();><A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Office</A> <A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Sales</A> <A
    href="http://www.javascriptindir.com/testet.asp?id=1226#">Customer Service</A>
    <A href="http://www.javascriptindir.com/testet.asp?id=1226#">Shipping</A>
    </DIV></LI></UL>

    </BODY>
    </HTML>


    menu.css

    #dd {
    PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 20px; MARGIN-LEFT: 25%; PADDING-TOP: 0px
    }
    #dd LI {
    PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FLOAT: left; PADDING-BOTTOM: 0px; MARGIN: 0px; FONT: bold 11px arial; PADDING-TOP: 0px; LIST-STYLE-TYPE: none
    }
    #dd LI A.menu {
    PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; BACKGROUND: #5970b2; PADDING-BOTTOM: 4px; MARGIN: 0px 1px 0px 0px; WIDTH: 60px; COLOR: #fff; PADDING-TOP: 4px; TEXT-ALIGN: center; TEXT-DECORATION: none
    }
    #dd LI A.menu:hover {
    BACKGROUND: #49a3ff
    }
    .submenu {
    BORDER-RIGHT: #5970b2 1px solid; BORDER-TOP: #5970b2 1px solid; Z-INDEX: 3; BACKGROUND: #eaebd8; VISIBILITY: hidden; BORDER-LEFT: #5970b2 1px solid; BORDER-BOTTOM: #5970b2 1px solid; POSITION: absolute
    }
    .submenu A {
    PADDING-RIGHT: 5px; DISPLAY: block; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; FONT: 11px arial; COLOR: #2875de; PADDING-TOP: 5px; TEXT-ALIGN: left; TEXT-DECORATION: none
    }
    .submenu A:hover {
    BACKGROUND: red; COLOR: #fff
    }



    < Bu mesaj bu kişi tarafından değiştirildi deryacom -- 17 Aralık 2007; 15:11:27 >




  • gerçekten güzel olmuş eline sağlık ama henüz tam site hazır değil sanırsam
  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
  • yok başka js kodlarıyla uğraşmakta daha doğrusu savaşmaktayım bakaım kim galip çıkacak
  • güzelmiş geliştirdiyseniz yeniside bayram hediyesi olrak isteriz =)
  • dinamik yapıyı öğren bir an önce mesela asp.net masterpage olayı veya php pageinclude olayı gibi

    < Bu ileti tablet sürüm kullanılarak atıldı >
  • bana yardım edermisiniz yukardaki menuyu yaptım ama aynı sayfada 2 farklı menu ypatım fakat hangisinin üstüne gelsem sadece birinin bilgileri açılyıor.çok kafam karıstı.A menusunun ustune geliyorum B nin submenuleri acılıyor.
    B menusune geliyorum yine b nin submenuleri açlıyor bundan nasıl krutulabilriim ?
  • yardım lütfen
  • pm attım
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.