7 Replies Latest reply on Aug 31, 2007 11:52 AM by Newsgroup_User

    Dreamweaver Template & Javascript

    akmagnolia
      I have a Dreamweaver template with this script:
      ------------------------------------------------------------------------------------------ -------------
      <SCRIPT type="text/javascript">
      <!--
      function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
      var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
      if (a .indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
      }

      function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a )&&x.oSrc;i++) x.src=x.oSrc;
      }

      function MM_findObj(n, d) { //v4.01
      var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms
      [n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers .document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
      }

      function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
      if ((x=MM_findObj(a
      ))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
      }

      // Comma separated list of images to rotate
      var imgs = new Array('images/northcampus/IMG_0587.JPG','images/northcampus/IMG_0593.JPG','images/northca mpus/IMG_0596.JPG','images/northcampus/IMG_0620.JPG','images/northcampus/IMG_0625.JPG');
      // delay in milliseconds between image swaps 1000 = 1 second
      var delay = 5000;
      var counter = 0;

      function preloadImgs(){
      for(var i=0;i<imgs.length;i++){
      MM_preloadImages(imgs );
      }
      }

      function randomImages(){
      if(counter == (imgs.length)){
      counter = 0;
      }
      MM_swapImage('rotator', '', imgs[counter++]);
      setTimeout('randomImages()', delay);
      }
      //-->
      </SCRIPT>
      ------------------------------------------------------------------------------------------ ------------------------

      When I create a new htmlpage & attach the template, the new page has extra code in my script! The last function turns out like this:
      ------------------------------------------------------------------------------------------ ---------------------
      function randomImages(){
      if(counter == (imgs.length)){
      counter = 0;
      }
      MM_swapImage('rotator', '', imgs[counter++]imgs
      );
      }
      }

      function randomImages(){
      if(counter == (imgs.length)){
      counter = 0;
      }
      MM_swapImage('rotator', '', imgs[counter++]);
      setTimeout('randomImages()', delay);
      }
      ------------------------------------------------------------------------------------------ ----------------

      How can I stop this from happening? It breaks my new page every time!
      Thanks for any ideas,
      nicki
        • 1. Re: Dreamweaver Template &amp; Javascript
          Level 7
          Upload the template file and post a link to it, please.

          --
          Murray --- ICQ 71997575
          Adobe Community Expert
          (If you *MUST* email me, don't LAUGH when you do so!)
          ==================
          http://www.dreamweavermx-templates.com - Template Triage!
          http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
          http://www.dwfaq.com - DW FAQs, Tutorials & Resources
          http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
          ==================


          "akmagnolia" <webforumsuser@macromedia.com> wrote in message
          news:fb7loi$8hd$1@forums.macromedia.com...
          >I have a Dreamweaver template with this script:
          >
          > --------------------------------------------------------------------------------
          > -----------------------
          > <SCRIPT type="text/javascript">
          > <!--
          > function MM_preloadImages() { //v3.0
          > var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
          > var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
          > i<a.length;
          > i++)
          > if (a .indexOf("#")!=0){ d.MM_p[j]=new Image;
          > d.MM_p[j++].src=a
          ;}}
          > }
          >
          > function MM_swapImgRestore() { //v3.0
          > var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a )&&x.oSrc;i++)
          > x.src=x.oSrc;
          > }
          >
          > function MM_findObj(n, d) { //v4.01
          > var p,i,x; if(!d) d=document;
          > if((p=n.indexOf("?"))>0&&parent.frames.length) {
          > d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
          > if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
          > x=d.forms
          [n];
          > for(i=0;!x&&d.layers&&i<d.layers.length;i++)
          > x=MM_findObj(n,d.layers .document);
          > if(!x && d.getElementById) x=d.getElementById(n); return x;
          > }
          >
          > function MM_swapImage() { //v3.0
          > var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
          > for(i=0;i<(a.length-2);i+=3)
          > if ((x=MM_findObj(a
          ))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
          > x.oSrc=x.src; x.src=a[i+2];}
          > }
          >
          > // Comma separated list of images to rotate
          > var imgs = new
          > Array('images/northcampus/IMG_0587.JPG','images/northcampus/IMG_0593.JPG','image
          > s/northcampus/IMG_0596.JPG','images/northcampus/IMG_0620.JPG','images/northcampu
          > s/IMG_0625.JPG');
          > // delay in milliseconds between image swaps 1000 = 1 second
          > var delay = 5000;
          > var counter = 0;
          >
          > function preloadImgs(){
          > for(var i=0;i<imgs.length;i++){
          > MM_preloadImages(imgs );
          > }
          > }
          >
          > function randomImages(){
          > if(counter == (imgs.length)){
          > counter = 0;
          > }
          > MM_swapImage('rotator', '', imgs[counter++]);
          > setTimeout('randomImages()', delay);
          > }
          > //-->
          > </SCRIPT>
          >
          > --------------------------------------------------------------------------------
          > ----------------------------------
          >
          > When I create a new htmlpage & attach the template, the new page has extra
          > code in my script! The last function turns out like this:
          >
          > --------------------------------------------------------------------------------
          > -------------------------------
          > function randomImages(){
          > if(counter == (imgs.length)){
          > counter = 0;
          > }
          > MM_swapImage('rotator', '', imgs[counter++]imgs
          );
          > }
          > }
          >
          > function randomImages(){
          > if(counter == (imgs.length)){
          > counter = 0;
          > }
          > MM_swapImage('rotator', '', imgs[counter++]);
          > setTimeout('randomImages()', delay);
          > }
          >
          > --------------------------------------------------------------------------------
          > --------------------------
          >
          > How can I stop this from happening? It breaks my new page every time!
          > Thanks for any ideas,
          > nicki
          >
          >


          • 2. Re: Dreamweaver Template &amp; Javascript
            akmagnolia Level 1
            The affected code is in my post.
            Has anyone experienced Dreamweaver rewriting javascript or adding extra javascript to a new file based on a template with javascript? It doesn't seem to matter if I have the script in an editable region or not, DW still adds the extra lines to it.
            • 3. Re: Dreamweaver Template &amp; Javascript
              Level 7
              Let's see the page, please.

              > Has anyone experienced Dreamweaver rewriting javascript or adding extra
              > javascript to a new file based on a template with javascript?

              Never. Not since DW2, writing the book on DW templates, and building > 100
              sites. Never.

              Showing us the template page will allow us to find things in the template
              that could be causing this.

              --
              Murray --- ICQ 71997575
              Adobe Community Expert
              (If you *MUST* email me, don't LAUGH when you do so!)
              ==================
              http://www.dreamweavermx-templates.com - Template Triage!
              http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
              http://www.dwfaq.com - DW FAQs, Tutorials & Resources
              http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
              ==================


              "akmagnolia" <webforumsuser@macromedia.com> wrote in message
              news:fb9gp8$alm$1@forums.macromedia.com...
              > The affected code is in my post.
              > Has anyone experienced Dreamweaver rewriting javascript or adding extra
              > javascript to a new file based on a template with javascript? It doesn't
              > seem
              > to matter if I have the script in an editable region or not, DW still adds
              > the
              > extra lines to it.
              >


              • 4. Re: Dreamweaver Template &amp; Javascript
                akmagnolia Level 1
                The template is basepageNCAMPUS.dwt, however, I couldn't download it through IE from this link. I made it an .html file so you can see that the image does rotate. The file ncmain.html is a file based on the template & the image does not rotate because the extra script was added by DW.

                http://fs8.fs.uaf.edu/vtabb/
                • 5. Re: Dreamweaver Template &amp; Javascript
                  Level 7
                  When troubleshooting things like this, it's always a good idea to begin with
                  a page that validates. Yours does not.

                  http://validator.w3.org/check?verbose=1&uri=http://fs8.fs.uaf.edu/vtabb/basepageNCAMPUS.ht ml

                  Luckily, all of these things would be relatively easy for you to fix:

                  1. <td width="5%" align="right" valign="bottom"
                  background=" http://www.uaf.edu/uaf/images/head/headbg.gif">

                  There is no background attribute for the <td> tag in HTML. Use CSS for this
                  background specification instead.

                  2. <map name="fs_banner" id="fs_banner">

                  You can only use a given ID assignment ONCE on any page. You have this one
                  at least three times.

                  3. <area shape="rect" coords="158,24,351,55"
                  href=" http://www.uaf.edu/fs/index.html" alt="UAF Facilities Services" />

                  Your page has an HTML doctype, so you should not use XHTML tag syntax.

                  4. <td valign="top"><span class="mainText"><br>

                  <!-- TemplateBeginEditable name="bodytext" -->

                  <p> </p>

                  You have a <p> (actually several) inside a <span> - that's illegal. You
                  cannot put block tags into inline containers.

                  5. <!-- end box definitions-->
                  </td></tr></table>

                  There is no corresponding opening table to go with these tags. The
                  </td></tr></table> should be deleted.

                  Fix those and let's see if the error continues to propagate.

                  --
                  Murray --- ICQ 71997575
                  Adobe Community Expert
                  (If you *MUST* email me, don't LAUGH when you do so!)
                  ==================
                  http://www.dreamweavermx-templates.com - Template Triage!
                  http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                  http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                  http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
                  ==================


                  "akmagnolia" <webforumsuser@macromedia.com> wrote in message
                  news:fb9i9h$c7n$1@forums.macromedia.com...
                  > The template is basepageNCAMPUS.dwt, however, I couldn't download it
                  > through IE
                  > from this link. I made it an .html file so you can see that the image does
                  > rotate. The file ncmain.html is a file based on the template & the image
                  > does
                  > not rotate because the extra script was added by DW.
                  >
                  > http://fs8.fs.uaf.edu/vtabb/
                  >


                  • 6. Re: Dreamweaver Template &amp; Javascript
                    akmagnolia Level 1
                    Well,
                    -- I cannot change #1-3 as they are code for a banner I am required to show & I didn't write the code.
                    -- I changed #4 & put the class in the td tag instead of a span.
                    -- The opening tag for that is
                    <!-- define main content white box -->
                    <table bgcolor="#ffffff" width="800" align="center"><tr><td>


                    -I uploaded new files, but DW still rewrites my javascript for new pages based on the template.
                    • 7. Re: Dreamweaver Template &amp; Javascript
                      Level 7
                      So - you have a page with invalid code that DW doesn't work well on, and you
                      cannot change the invalid code? I'm not sure I understand why you cannot
                      change this in your template. What difference would it make other than to
                      give your page a chance of validating?

                      Zip the template and its associated files and email them to me at

                      forums at great-web-sights dot com

                      I'll take a look.

                      --
                      Murray --- ICQ 71997575
                      Adobe Community Expert
                      (If you *MUST* email me, don't LAUGH when you do so!)
                      ==================
                      http://www.dreamweavermx-templates.com - Template Triage!
                      http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                      http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                      http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
                      ==================


                      "akmagnolia" <webforumsuser@macromedia.com> wrote in message
                      news:fb9m18$g70$1@forums.macromedia.com...
                      > Well,
                      > -- I cannot change #1-3 as they are code for a banner I am required to
                      > show &
                      > I didn't write the code.
                      > -- I changed #4 & put the class in the td tag instead of a span.
                      > -- The opening tag for that is
                      > <!-- define main content white box -->
                      > <table bgcolor="#ffffff" width="800" align="center"><tr><td>
                      >
                      >
                      > -I uploaded new files, but DW still rewrites my javascript for new pages
                      > based
                      > on the template.
                      >