Announcement

Collapse
No announcement yet.

Adding javascripts?

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

    Adding javascripts?

    I have tried adding some simple javascripts in both fragments and in the layout, the latter works fine in the preview but nothing shows in the published site.

    I have tried wrapping the code in tags like I have to with html and still nothing, am I missing something really basic?

    Searched the forum but cant seem to find my issue...


    Thanks Ed
    https://www.harrisontelescopes.co.uk/

    Ed Harrison - Menmuir Scotland

    #2
    Show us what you have done would be a good start.

    Comment


      #3
      Ok...this is an example of what I dropped in and looked fine in the preview but invisible when published:

      Code:
      <script type="text/javascript">
      // Highlighter Scroller II script- By JavaScript Kit (http://www.javascriptkit.com)
      // For this and over 400+ free scripts, visit http://www.javascriptkit.com/
      // This notice must stay intact
      
      //CONFIGURE MESSAGES AND VARIABLES
      var tickercontents=new Array()
      tickercontents[0]='Connect your Digital SLR camera to your Telescope <a href="http://www.harrisontelescopes.co.uk/acatalog/DSLR_Adaptors.html">Click Here</a>!'
      tickercontents[1]='Discounts on <a href="http://www.harrisontelescopes.co.uk/acatalog/Celestron_NexStar_Telescopes.html">Celestron NexStar Telescopes</a> From £219!'
      tickercontents[2]='Giant <a href="http://www.harrisontelescopes.co.uk/acatalog/Revelation_20x100_Binocular_With_Nebula_Filters.html">20x100 Binoculars</a> with built in Nebula filters £249 Delivered!'
      
      var tickerwidth="500px"
      var tickerheight="70px"
      var fontcss="font: bold 14px Tahoma; color:lightblue"
      var tickdelay=3000 //delay btw messages
      var highlightspeed=2 //2 pixels at a time.
      var highlightcolor="black"
      var backdroptextcolor="#E1E1E1"
      
      ////Do not edit pass this line////////////////
      
      document.write('<style>#highlighterbg a{color:'+backdroptextcolor+'}</style>')
      document.write('<div style="position:relative;left:0px;top:0px; width:'+tickerwidth+'; height:'+tickerheight+';'+fontcss+'">')
      document.write('<span id="highlighterbg" style="position:absolute;left:0;top:0;color:'+backdroptextcolor+'; width:'+tickerwidth+'; height:'+tickerheight+';padding: 4px"></span><span id="highlighter" style="position:absolute;left:0;top:0;clip:rect(auto auto auto 0px); background-color:'+highlightcolor+'; width:'+tickerwidth+';height:'+tickerheight+';padding: 4px"></span>')
      document.write('</div>')
      
      var currentmessage=0
      var clipbottom=1
      
      function changetickercontent(){
      msgheight=clipbottom=crosstick.offsetHeight
      crosstick.style.clip="rect("+msgheight+"px auto auto 0px)"
      crosstickbg.innerHTML=tickercontents[currentmessage]
      crosstick.innerHTML=tickercontents[currentmessage]
      highlightmsg()
      }
      
      function highlightmsg(){
      //var msgheight=crosstick.offsetHeight
      if (clipbottom>0){
      clipbottom-=highlightspeed
      crosstick.style.clip="rect("+clipbottom+"px auto auto 0px)"
      beginclip=setTimeout("highlightmsg()",20)
      }
      else{
      clipbottom=msgheight
      clearTimeout(beginclip)
      if (currentmessage==tickercontents.length-1) currentmessage=0
      else currentmessage++
      setTimeout("changetickercontent()",tickdelay)
      }
      }
      
      function start_ticking(){
      crosstickbg=document.getElementById? document.getElementById("highlighterbg") : document.all.highlighterbg
      crosstick=document.getElementById? document.getElementById("highlighter") : document.all.highlighter
      crosstickParent=crosstick.parentNode? crosstick.parentNode : crosstick.parentElement
      if (parseInt(crosstick.offsetHeight)>0)
      crosstickParent.style.height=crosstick.offsetHeight+'px'
      else
      setTimeout("crosstickParent.style.height=crosstick.offsetHeight+'px'",100) //delay for Mozilla's sake
      changetickercontent()
      }
      
      if (document.all || document.getElementById)
      window.onload=start_ticking
      </script>
      https://www.harrisontelescopes.co.uk/

      Ed Harrison - Menmuir Scotland

      Comment


        #4
        One way would be to place the js in a text file then create a custom variable of type 'file content' then place the variable in the layout where you want it with a block around it to only show if not empty.....but there's probably other methods...

        Comment


          #5
          i think you need to check the code and anywhere you have something in [] it should have spaces. ie [ 0 ] instead of [0]
          ***************************************
          Water is both ordered and flexible at the same time. It maintains its own identity, but conforms as necessary to the circumstances around it.

          -Miyamoto Musashi - The Book of Five Rings

          Jake
          Buy Fire Extinguishers
          Fire Extinguishers

          Comment


            #6
            Quite right Jake, Actinic's not parsing any variabls after doing that, but I think there may be a bit more to this as doing that still doesn't work in a fragment.

            Comment


              #7
              Originally posted by Firecom View Post
              i think you need to check the code and anywhere you have something in [] it should have spaces. ie [ 0 ] instead of [0]
              This shouldn't have any difference in javascript - is this an Actinic parsing thing?

              I would have prefered to see the start_ticking function called in the <BODY OnLoad="">

              Comment


                #8
                Looking at the page source when using it in a fragment (with [ 0 ]) then the js it looks correct but doesn't execute, however placing the same code directly in a layout works fine.
                Another odd but 'easy when you know issue' I suspect.

                Comment


                  #9
                  Originally posted by acompton View Post
                  This shouldn't have any difference in javascript - is this an Actinic parsing thing?
                  Yes - Sir Norman discovered the workaround with the spacing.


                  Bikster
                  SellerDeck Designs and Responsive Themes

                  Comment


                    #10
                    How we miss 'the man'.
                    Oddly it doesn't seem to be the only thing in this case though.

                    Comment


                      #11
                      You can avoid any Actinic parsing problems by putting the whole function into the actinicextras.js file and then just calling the start_ticking function on pages as required using <BODY OnLoad=""> and some 'block ifs' as necessary.
                      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


                        #12
                        Thanks, I will play again later, even if it just works in the layout I can live with that, would be nice in fragments too...

                        Ed
                        https://www.harrisontelescopes.co.uk/

                        Ed Harrison - Menmuir Scotland

                        Comment

                        Working...
                        X