+ Reply to Thread
Results 1 to 10 of 10

Thread: javascript alert message problem

  1. #1
    Otaku Ichise's Avatar
    Otaku Ichise is offline x10Hosting Member Otaku Ichise is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Portugal
    Posts
    64

    javascript alert message problem

    http://otakushrine.elementfx.com/

    its not working because of the other 2 javascripts i have, altough i made them external .js files, it still doesnt work... i started learning it today, hope you can see my problem here :happysad:

  2. #2
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: javascript alert message problem

    Hmm, I can't access the web site...

    perhaps if you post the code...
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

  3. #3
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: javascript alert message problem

    Move the javascript code below the <body> tag.

    Like so:

    HTML Code:
    <body onload="message();">
    <script type="text/javascript">
    function message()
    {
    alert("currently working on another website and learning javascript");
    }
    </script>
    ....

  4. #4
    Otaku Ichise's Avatar
    Otaku Ichise is offline x10Hosting Member Otaku Ichise is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Portugal
    Posts
    64

    Re: javascript alert message problem

    Quote Originally Posted by VPmase View Post
    Move the javascript code below the <body> tag.

    Like so:

    HTML Code:
    <body onload="message();">
    <script type="text/javascript">
    function message()
    {
    alert("currently working on another website and learning javascript");
    }
    </script>
    ....
    still doesnt work.

  5. #5
    daman371 is offline x10 Sophmore daman371 is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Louisiana
    Posts
    130

    Re: javascript alert message problem

    Code:
    <script type="text/javascript">
    function message()
    {
    alert("currently working on another website and learning javascript");
    }
    </script>
    <body onLoad="javascript:message();">
    Also acceptable:

    Code:
    <script type="text/javascript">
    function message()
    {
    alert("currently working on another website and learning javascript");
    }
    </script>
    <body onLoad="message();">
    Last edited by daman371; 09-17-2008 at 08:09 PM.

  6. #6
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: javascript alert message problem

    Quote Originally Posted by Otaku Ichise View Post
    still doesnt work.
    I went through your code and noticed that time.js doesn't exist even though you call it in your page.

    <script src="index_files/time.js"></script>

    That line was what makes it not run right.

  7. #7
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: javascript alert message problem

    Yep, try removing all other javascripts first, then when you add them, if they break it, you know where the problem is!
    If the following code is on your page, without any other script, it will work:
    Code:
    <head>
    ...
    <script type="text/javascript">
    function message() {
     alert("Welcome");
    }
    </script>
    </head>
    <body onLoad="message();">
    ...
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

  8. #8
    Otaku Ichise's Avatar
    Otaku Ichise is offline x10Hosting Member Otaku Ichise is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Portugal
    Posts
    64

    Re: javascript alert message problem

    I mentioned above the script alert message works only if i take those 2 other .js scripts, somehow they cancel the alert message and the code inside .js files is this:

    Date.js
    //<![CDATA[
    /*Current date script credit:
    JavaScript Kit (www.javascriptkit.com)
    */
    var mydate=new Date()
    var year=mydate.getYear()
    if (year < 1000)
    year+=1900
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    if (daym<10)
    daym="0"+daym
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday")
    var montharray=new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December")
    document.write("<font color='#BBD6EC' face='Palatino Linotype'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font>")
    //]]>
    time.js
    //<![CDATA[
    /*By JavaScript Kit
    http://javascriptkit.com
    Credit MUST stay intact for use
    */
    function show2(){
    if (!document.all&&!document.getElementById)
    return
    thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2
    var Digital=new Date()
    var hours=Digital.getHours()
    var minutes=Digital.getMinutes()
    var seconds=Digital.getSeconds()
    var dn="PM"
    if (hours<12)
    dn="AM"
    if (hours>12)
    hours=hours-12
    if (hours==0)
    hours=12
    if (minutes<=9)
    minutes="0"+minutes
    if (seconds<=9)
    seconds="0"+seconds
    var ctime=hours+":"+minutes+":"+seconds+" "+dn
    thelement.innerHTML="<b style='color:#BBD6EC; font-family:times new roman'>"+ctime+"</b>"
    setTimeout("show2()",1000)
    }
    window.onload=show2
    //]]>
    Last edited by Otaku Ichise; 09-18-2008 at 11:08 AM.

  9. #9
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: javascript alert message problem

    Use this for your time.js

    Code:
    //<![CDATA[
    /*By JavaScript Kit
    http://javascriptkit.com
    Credit MUST stay intact for use
    */
    function show2(){
    if (!document.all&&!document.getElementById){
    return;}
    thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2;
    var Digital=new Date();
    var hours=Digital.getHours();
    var minutes=Digital.getMinutes();
    var seconds=Digital.getSeconds();
    var dn="PM";
    if (hours<12){
    dn="AM";}
    if (hours>12){
    hours=hours-12;}
    if (hours==0){
    hours=12;}
    if (minutes<=9){
    minutes="0"+minutes;}
    if (seconds<=9){
    seconds="0"+seconds;}
    var ctime=hours+":"+minutes+":"+seconds+" "+dn;
    thelement.innerHTML="<b style='color:#BBD6EC; font-family:times new roman'>"+ctime+"</b>";
    setTimeout(show2(),1000);
    }
    window.onload=show2();
    //]]>
    I cleaned up your script. You should really use semicolons (;)...

  10. #10
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: javascript alert message problem

    Yep those scripts were the problem.

    I'd suggest replacing the Date script with the following (much shorter) php:
    PHP Code:
    <?php
    $dat
    =date("D jS F Y");
    echo 
    "<font color='#BBD6EC' face='Palatino Linotype'><b>$dat</b></font>";
    ?>
    look up the date() function for additional information
    Last edited by mattura; 09-19-2008 at 03:12 AM.
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

+ Reply to Thread

Similar Threads

  1. iframe javascript problem
    By oracle in forum Programming Help
    Replies: 5
    Last Post: 06-29-2008, 12:56 PM
  2. Javascript maths problem
    By slpixe in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 06-15-2008, 06:34 PM
  3. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  4. Replies: 2
    Last Post: 12-14-2007, 09:21 AM
  5. Ftp Timeout problem
    By ironcross77 in forum Free Hosting
    Replies: 7
    Last Post: 04-12-2005, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers