SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    malaysia
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    After "include" then cannot "onLoad"?????

    Can anyone help me on it? I find it and found for many source but not talking about.After I include some file then the onload function do not work! this is my code....
    <html>
    <script language="javascript">
    function test(){
    alert("testing");
    }
    </SCRIPT>
    <body leftmargin="0" topmargin="0" onload="test()">
    <h4>Catalog</h4>

    </body>
    </html>
    <html>
    it work. but if i include my logo or sideframe... it cannot work... here is the code:

    <script language="javascript">
    function test(){
    alert("testing");
    }
    </SCRIPT>
    <body leftmargin="0" topmargin="0" onload="test()" >
    <%@ include file="topFrame.jsp" %>
    <h4>Catalog : New Marc</h4>
    <%@ include file="sideFrame.jsp" %>

    </body>
    </html>
    it cannot work!!Pls help me!

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Check those included pages for any javascript that conflicts with onload of main page.

    Afru.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    malaysia
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank Afru....
    sorry, finally i find tt... the include page oledi got 1 onload,
    window.onload=show

    so? if i want to load both of them, can i?

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function myownfunction(){
    somework1();
    somework2();
    somework3();
    //as many as you want.
    }
    
    window.onload=myownfunction;
    Hope you got it...

    Afru.

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by afru
    Code:
    function myownfunction(){
    somework1();
    somework2();
    somework3();
    //as many as you want.
    }
    
    window.onload=myownfunction;
    Hope you got it...

    Afru.
    That's not going to work because of the order of the poster's <scripts>: somework1(), somework2(), etc. will be undefined.

    Try moving your <script> to just before the </body> tag, and using this code:
    Code:
    var oldfuncs = window.onload;
    window.onload = function()
    {
        oldfuncs();
        test();
    };


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •