Announcement

Collapse
No announcement yet.

Javascript inside a fragment.

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

    #16
    Hi Jont
    Many thanks for the quick and helpful reply.
    I'm embarrassed to say it seems as though my "copy & paste" EVERYTHING function wasn't working when I inserted the script!

    However I have now copied & pasted correctly and now nothing at all appears on the page!
    Clearly there is something in this script that Actinic doesn't like, no there's a novelty, but I am bu88ered if I can see what it is.

    The script works perfectly on a plain html page but not in the confounded fragment.

    Here is the correct script for those wiser than me, so just about everyone on here, to have a butchers at and hopefully tell me how I can get it to run.

    !!<<SCRIPT language=JavaScript>
    /*
    +---------------------------------------------------------+
    | Ad Simple Copyright www.YugDesign.com |
    +---------------------------------------------------------+
    | This program may be used and hosted free of charge by |
    |anyone for personal purpose as long as this copyright |
    |notice remains intact. |
    +---------------------------------------------------------+
    */

    var ad=new Array()
    ad[ 0 ]='I have just received delivery of my order and would like to say how pleased I was and also thanks for substituting the parasol as the one I ordered was out of stock, it would have made it inconvenient if you'd not sent a sustitute. I am very grateful.

    Regards - Janet Close';
    ad[ 1 ]='Thank you very much for the hand fans which we received this morning. I know they will help towards our fundraising. You are very kind to help us and it is much appreciated.

    Thanks and Best Wishes,

    Lyn ';
    ad[ 3 ]='Text 4';
    ad[ 4 ]='Text 5';
    ad[ 5 ]='Text 6';
    ad[ 6 ]='Text 7';
    ad[ 7 ]='Text 8';
    ad[ 8 ]='Text 9';
    ad[ 9 ]='Text 10';

    var xy=Math.floor(Math.random()*ad.length);
    document.write(ad[ xy ]);

    </SCRIPT>>!!

    Comment


      #17
      Preview a page then copy / paste the Preview URL into Firefox. In Firefox go to Tools / Error Console and you'll get decent diagnostics.

      You might want to try making your initial text very short and only expand it when things are working.

      Also watch out for embedded quote characters. You have (sic)
      Code:
      '... inconvenient if you'd not sent a sustitute ...'
      and that quote in the middle will break things. You need to escape it thus
      Code:
      '... inconvenient if you\'d not sent a sustitute ...'
      Also such lines are safest if they are single long lines.
      Finally, if posting snippets of code, put them between [ c o d e ] and [ / c o d e ] tags (without the spaces) as it makes it much easier for us to read.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #18
        Norman
        Many thanks I am humbled.
        It turns out that there was a problem with an unterminated string literal and also a missing ; statement!

        I am now 110% more clued up on Javascript than I was last night.

        For those that would like to use the now working code here it is.
        It simply rotates customer testimonials or comments or images.
        Code:
         !!<<SCRIPT language=JavaScript>
        /*
         +---------------------------------------------------------+
         | Ad Simple                 Copyright www.YugDesign.com   |
         +---------------------------------------------------------+
         | This program may be used and hosted free of charge by   |
         |anyone for personal purpose as long as this copyright    |
         |notice remains intact.                                   |
         +---------------------------------------------------------+
        */
        
        var ad=new Array()
        ad[ 0 ]='Text 0';
        ad[ 1 ]='Text 1 ';
        ad[ 2 ]='Text 2';
        ad[ 3 ]='Text 3';
        ad[ 4 ]='Text 4';
        ad[ 5 ]='Text 5';
        
        var xy=Math.floor(Math.random()*ad.length);
        document.write(ad[ xy ]);
        
        </SCRIPT>>!!

        Comment


          #19
          Now you can bulk it back up to what you need. You could also put your text strings in double quotes and then you'll be able to use single quotes without escaping them. E.g.

          ad[ 0 ]="Plenty O'Tool";

          I wouldn't feel too bad about removing that copyright notice. That lump of code is trivial and you'll already find very similar bits already posted here (I recall doing an almost identical post for random images).
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #20
            Thanks Norman.
            I get it,

            ad[ 0 ]=Plenty: 'Hi, I'm Plenty.'
            Bond: 'But of course you are.'
            Plenty: 'Plenty O'Tool'
            Bond: 'Named after your father perhaps.';

            Great film!

            Comment


              #21
              Dynamic Scrollers

              I`m trying to get this Scroller to work but it wont even appear on the Fragment. Ive tried all the fixes from Norman but no joy. Actinic says ive got a Script Error.

              Any help would be great.

              Cheers
              Ricc

              HTML Code:
              !!<<script type="text/javascript">
              var delay = 2000; //set delay between message change (in miliseconds)
              var maxsteps=30; // number of steps to take to change from start color to endcolor
              var stepdelay=40; // time in miliseconds of a single step
              //**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
              var startcolor= new Array(255,255,255); // start color (red, green, blue)
              var endcolor=new Array(0,0,0); // end color (red, green, blue)
              
              var fcontent=new Array();
              begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarations
              fcontent[ 0 ]="<b>What\'s new?</b><br>New scripts added to the Scroller category!<br><br>The MoreZone has been updated. <a href='../morezone/index.htm'>Click here to visit</a>";
              fcontent[ 1 ]="Dynamic Drive has been featured on Jars as a top 5% resource, and About.com as a recommended DHTML destination.";
              fcontent [ 2 ]="Ok, enough with these pointless messages. You get the idea behind this script.</a>";
              closetag='</div>';
              
              var fwidth='150px'; //set scroller width
              var fheight='150px'; //set scroller height
              
              var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.
              
              ///No need to edit below this line/////////////////
              
              
              var ie4=document.all&&!document.getElementById;
              var DOM2=document.getElementById;
              var faderdelay=0;
              var index=0;
              
              
              /*Rafael Raposo edited function*/
              //function to change content
              function changecontent(){
                if (index>=fcontent.length)
                  index=0
                if (DOM2){
                  document.getElementById("fscroller").style.color="rgb("+startcolor[ 0 ]+", "+startcolor[ 1 ]+", "+startcolor[ 2 ]+")"
                  document.getElementById("fscroller").innerHTML=begintag+fcontent[ index ]+closetag
                  if (fadelinks)
                    linkcolorchange(1);
                  colorfade(1, 15);
                }
                else if (ie4)
                  document.all.fscroller.innerHTML=begintag+fcontent[ index ]+closetag;
                index++
              }
              
              // colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
              // Modified by Dynamicdrive.com
              
              function linkcolorchange(step){
                var obj=document.getElementById("fscroller").getElementsByTagName("A");
                if (obj.length>0){
                  for (i=0;i<obj.length;i++)
                    obj[i].style.color=getstepcolor(step);
                }
              }
              
              /*Rafael Raposo edited function*/
              var fadecounter;
              function colorfade(step) {
                if(step<=maxsteps) {	
                  document.getElementById("fscroller").style.color=getstepcolor(step);
                  if (fadelinks)
                    linkcolorchange(step);
                  step++;
                  fadecounter=setTimeout("colorfade("+step+")",stepdelay);
                }else{
                  clearTimeout(fadecounter);
                  document.getElementById("fscroller").style.color="rgb("+endcolor[ 0 ]+", "+endcolor[ 1 ]+", "+endcolor[ 2 ]+")";
                  setTimeout("changecontent()", delay);
              	
                }   
              }
              
              /*Rafael Raposo's new function*/
              function getstepcolor(step) {
                var diff
                var newcolor=new Array(3);
                for(var i=0;i<3;i++) {
                  diff = (startcolor[ i ]-endcolor[ i ]);
                  if(diff > 0) {
                    newcolor[ i ] = startcolor[ i ]-(Math.round((diff/maxsteps))*step);
                  } else {
                    newcolor[ i ] = startcolor[ i ]+(Math.round((Math.abs(diff)/maxsteps))*step);
                  }
                }
                return ("rgb(" + newcolor[ 0 ] + ", " + newcolor[ 1 ] + ", " + newcolor[ 2 ] + ")");
              }
              
              if (ie4||DOM2)
                document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');
              
              if (window.addEventListener)
              window.addEventListener("load", changecontent, false)
              else if (window.attachEvent)
              window.attachEvent("onload", changecontent)
              else if (document.getElementById)
              window.onload=changecontent
              
              </script>>!!
              http://www.marionvillemodels.com http://www.skymonster.com

              Comment


                #22
                Have you got Firefox installed with the Firebug add-on? If you preview the page in that and look at the Error Console you will get some more detailed info about your script error. With Firebug you can properly debug the javascript too by adding breakpoints, watches, etc.
                ActiveStock
                On-line, real-time stock control plug-in for Actinic V7, V8 and V9
                **New - Captcha plug-in for your Contact Us form**

                ActiveStock website
                Free 30 Day Trial
                ActiveStock Blog (including a new tutorial on a 'Sort By' function for long section pages)

                Comment


                  #23
                  Originally posted by rmorrow View Post
                  Have you got Firefox installed with the Firebug add-on? If you preview the page in that and look at the Error Console you will get some more detailed info about your script error. With Firebug you can properly debug the javascript too by adding breakpoints, watches, etc.
                  Just tried it but no errors. I use the same scroller on an HTML site with no problems, it seem to be somthing with actinic.
                  http://www.marionvillemodels.com http://www.skymonster.com

                  Comment


                    #24
                    Can't you go external JS with the uneditable part and copy the actinic way of doing things? I do this with items like this when adding into fragments and get no issues, just make sure the file is in the site root.

                    Comment


                      #25
                      Originally posted by leehack View Post
                      Can't you go external JS with the uneditable part and copy the actinic way of doing things? I do this with items like this when adding into fragments and get no issues, just make sure the file is in the site root.
                      How do I do that, My skills are basic....
                      http://www.marionvillemodels.com http://www.skymonster.com

                      Comment


                        #26
                        None of the JavaScript uses any Actinic content so it can all be moved to a file "scroller.js" in your Site folder. Move everything except the first and lst lines and replace these (in your Fragment) with:
                        Code:
                        !!<<script language="JavaScript" type="text/javascript" src="scroller.js"></script>>!!
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #27
                          Originally posted by NormanRouxel View Post
                          None of the JavaScript uses any Actinic content so it can all be moved to a file "scroller.js" in your Site folder. Move everything except the first and last lines and replace these (in your Fragment) with:
                          Code:
                          !!<<script language="JavaScript" type="text/javascript" src="scroller.js"></script>>!!
                          Spot on once again Norman. What would Actinic do with out you guys.

                          Cheers
                          Ricc
                          http://www.marionvillemodels.com http://www.skymonster.com

                          Comment


                            #28
                            I have been trying to get this working on my site bit with little success.

                            I have tried all above that is suggested and also as js file and again nothing.

                            This is the code that is generated from the site.

                            <script language="JavaScript">
                            <!--

                            function random_imglink(){
                            var myimages=new Array()
                            //specify random images below. You can have as many as you wish
                            myimages[ 1 ]="img1.jpg"
                            myimages[ 2 ]="img2.jpg"
                            myimages[ 3 ]="img3.jpg"

                            //specify corresponding links below
                            var imagelinks=new Array()
                            imagelinks[ 1 ]="http://www.url.com"
                            imagelinks[ 2 ]="http://www.url.com"
                            imagelinks[ 3 ]="http://www.url.net"

                            var ry=Math.floor(Math.random()*myimages.length)

                            if (ry==0)
                            ry=1
                            document.write('<a href='+'"'+imagelinks[ ry ]+'"'+'><img src="'+myimages[ ry ]+'" border=0></a>')
                            }

                            random_imglink()
                            //-->
                            </script>


                            any help would be great.

                            Thanks

                            Comment


                              #29
                              Help: Don't double post!
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X