DHTML and javascript not working on the same page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • sarah85
    Sergeant

    • Nov 2007
    • 24

    DHTML and javascript not working on the same page

    Hi

    I have made digital timer using javascript and a floating image using DHTML, they are working fine but on one page i put both of those scripts ,after that timer was not shown and when i removed timer script from the page the floating image started working,either of the two works when i put both scripts on same page, is there any way that both of those scripts work if applied on the same page? why does it block the other?
  • VodaHost
    General & Forum Administrator

    • Mar 2005
    • 12356

    #2
    Re: DHTML and javascript not working on the same page

    1) Click Here.
    2) Sounds like you are having some type of code conflict.

    VodaHost

    Your Website People!
    1-302-283-3777 North America / International
    02036089024 / United Kingdom
    291916438 / Australia

    ------------------------

    Top 3 Best Sellers

    Web Hosting - Unlimited disk space & bandwidth.

    Reseller Hosting - Start your own web hosting business.

    Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)


    Comment

    • sarah85
      Sergeant

      • Nov 2007
      • 24

      #3
      Re: DHTML and javascript not working on the same page

      Originally posted by VodaHost View Post
      1) Click Here.
      2) Sounds like you are having some type of code conflict.

      Hey,

      Is there anyway i can avoid this code conflict on the page?

      Here is the digital timer's script

      <span id=tick2>
      </span>

      <script>
      <!--
      /*
      By George Chiang (WA's JavaScript tutorial)
      http://wsabstract.com
      */
      function show2(){
      if (!document.all)
      return

      var Digital=new Date()
      var hours=Digital.getHours()
      var minutes=Digital.getMinutes()
      var seconds=Digital.getSeconds()
      var dn="AM"

      if (hours>12){
      dn="PM"
      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
      tick2.innerHTML="<b style='font-size:14;color:white;'>"+ctime+"</b>"
      setTimeout("show2()",1000)
      }

      window.onload=show2
      //-->
      </script>




      and here is the floating image script which i have written in html part of the template (bluevoda template).

      <div id="point1" STYLE="position:absolute;visibility:visible;">
      <!--Please delete this table and insert into your html elements-->
      <table border="0" cellspacing="0" cellpadding="0">
      <tr>
      <td>
      <a href="http://www.flair*******.com">
      <img src="C:\Documents and Settings\Aaliya Shahnawaz\My Documents\BlueVoda\Images\logo.jpg" width=150 height=200 alt="" border="1">
      </a>
      </td>
      </tr>
      <tr>
      <td>
      <center>
      <font face="Arial" size="2" color="red">CLICK on image to</font>
      </center>
      </td>
      </tr>
      <tr>
      <td>
      <center>
      <font face="Arial" size="2" color="red">View FLAIR models</font>
      </center>
      </td>
      </tr>
      </table>
      <!--End of the customizable area, please do not delete div the tag -->
      </div>

      <script LANGUAGE="JavaScript1.2">
      /*
      Floating image II (up down)- Bruce Anderson (http://*****tlib.tr****.com)
      Submitted to Dynamicdrive.com to feature script in archive
      Modified by DD for script to function in NS6
      For 100's of FREE DHTML scripts, Visit http://www.dynamicdrive.com
      */
      var XX=30; // X position of the scrolling objects
      var xstep=1;
      var delay_time=60;
      //Begin of the unchangable area, please do not modify this area
      var YY=0;
      var ch=0;
      var oh=0;
      var yon=0;
      var ns4=document.layers?1:0
      var ie=document.all?1:0
      var ns6=document.getElementById&&!document.all?1:0
      if(ie){
      YY=document.body.clientHeight;
      point1.style.top=YY;
      }
      else if (ns4){
      YY=window.innerHeight;
      document.point1.pageY=YY;
      document.point1.visibility="hidden";
      }
      else if (ns6){
      YY=window.innerHeight
      document.getElementById('point1').style.top=YY
      }

      function reloc1()
      {
      if(yon==0){YY=YY-xstep;}
      else{YY=YY+xstep;}
      if (ie){
      ch=document.body.clientHeight;
      oh=point1.offsetHeight;
      }
      else if (ns4){
      ch=window.innerHeight;
      oh=document.point1.clip.height;
      }
      else if (ns6){
      ch=window.innerHeight
      oh=document.getElementById("point1").offsetHeight
      }

      if(YY<0){yon=1;YY=0;}
      if(YY>=(ch-oh)){yon=0;YY=(ch-oh);}
      if(ie){
      point1.style.left=XX;
      point1.style.top=YY+document.body.scrollTop;
      }
      else if (ns4){
      document.point1.pageX=XX;
      document.point1.pageY=YY+window.pageYOffset;
      }
      else if (ns6){
      document.getElementById("point1").style.left=XX
      document.getElementById("point1").style.top=YY+win dow.pageYOffset
      }
      }
      function onad()
      {
      if(ns4)
      document.point1.visibility="visible";
      loopfunc();
      }
      function loopfunc()
      {
      reloc1();
      setTimeout('loopfunc()',delay_time);
      }
      if (ie||ns4||ns6)
      window.onload=onad
      </script>

      Comment

      • Aliens Anonymous
        Special Status

        • Jan 2006
        • 1144

        #4
        Re: DHTML and javascript not working on the same page

        May first say to use the words
        and here is the floating image script which i have written in html
        should only be used when, and Only when you have written the script, words like, changed, manipulated, altered, can be used when dealing with others work. Dynamic Drive and JavaScript Kit go to great lengths to copy wright any of the FREE scripts on their sites.

        Having said that ***** is right in the script conflict as you have found, if you use the scripts and implement the changes within the <div> tags only both scripts will work correctly as seen Here .
        also the image url or src is wrong
        <img src="C:\Documents and Settings\Aaliya Shahnawaz\My Documents\BlueVoda\Images\logo.jpg" width=150 height=200 alt="" border="1">

        depending on were the page is and were the image is located should be
        <img src="logo.jpg" or <img src="images/logo.jpg" or full url if image is a folder down from the page.

        Comment

        Working...
        X