Announcement

Collapse
No announcement yet.

Javascript inside a fragment.

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

    Javascript inside a fragment.

    Actinic doesn't seem to want to run the javascript I have in my fragment.

    If I make a simple <HTML><BODY> etc file and put the javascript in - it works perfectly, however not inside the fragment. Am I missing a step as actinic seems to insert its own junk inside it?

    Below is the code before

    HTML Code:
    <script language="JavaScript">
    <!--
    
    function random_imglink(){
      var myimages=new Array()
      //specify random images below. You can have as many as you wish
      myimages[1]="logo.jpg"
      myimages[2]="logo2.jpg"
      myimages[3]="logo3.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>
    Code once actinic has had a hold of it
    HTML Code:
    <script language="JavaScript">
    <!--
    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages<Actinic:Variable Name = '1'/>="http://www.gilmoursportsfieldhockey.com/acatalog/logo.jpg"
    myimages<Actinic:Variable Name = '2'/>="http://www.gilmoursportsfieldhockey.com/acatalog/logo.jpg"
    myimages<Actinic:Variable Name = '3'/>="http://www.gilmoursportsfieldhockey.com/acatalog/logo.jpg"
    //specify corresponding links below
    var imagelinks=new Array()
    imagelinks<Actinic:Variable Name = '1'/>="http://www.wsabstract.com"
    imagelinks<Actinic:Variable Name = '2'/>="http://www.dynamicdrive.com"
    imagelinks<Actinic:Variable Name = '3'/>="http://www.java-scripts.net"
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<a href='+'"'+imagelinks<Actinic:Variable Name = 'ry'/>+'"'+'><img src="'+myimages<Actinic:Variable Name = 'ry'/>+'" border=0></a>')
    }
    random_imglink()
    //-->
    
    </script>

    #2
    Are you embedding it using the !!< html >!! markers?

    Comment


      #3
      Haha, of course :P

      Comment


        #4
        Actinic tries to parse things within square brackets as Variables.

        The fix is to use spaces inside the brackets. Change:

        myimages[1]="logo.jpg"

        to:

        myimages[ 1 ]="logo.jpg"

        which luckily is still valid JavaScript.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          square brackets
          ...or, in my head, 'squackets'.

          Comment


            #6
            Thanks very much

            Worked A treat

            Comment


              #7
              Go on Gabe.... What are {} () and <> then?
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                squiggly curlets, brackets and fighting crocodiles, obviously.

                Comment


                  #9
                  Another problem now hehe.

                  Any reason why actinic seems to just die when I add this bit of code into a table.

                  Its a fairly simple table. 2 colums / 2 rows. Each 'cell' has this chunk of code in it to randomly display a certain image.

                  Actinic just dies. It doesn't crash - it allows me to look through the file menus but not press anything. I cant get away from the fragment either and I can click the big X until the cows come home, however the application never dies and has to have the process stopped. Which means it doesn't remember what ive just done to the fragment.

                  Perhaps im going about the coding the wrong way, however once again it works perfectly fine on a normal html file.

                  Comment


                    #10
                    it might be smart to put your advert logic into an external js file and then include it in your fragment.

                    I cant see a reason why actinic would kack out for this.

                    try restarting Actinic and/or the computer too?

                    Comment


                      #11
                      Very odd indeed.

                      Works perfectly fine with an external js file. Bit of overkill for a tiny script though

                      Comment


                        #12
                        classic kludge

                        Comment


                          #13
                          Gordon

                          If you search for "random images", you'll find several prior posts, including some V8/9 code that uses Variables to hold thhose images and URL's. A lot more useful and maintainable than hard-coding them in.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            Running Actinic 8.5.2.0.0.0 HMVA on XP

                            I've tried to get the Javascript below to run inside a fragment following the excellent advice above and it just won't have it. All I get is everything you see below showing up on the page. I am well aware I am probably being dumb again, Javascript is not my first language, but any advice, kind or otherwise, could push my education to a giddy new level!

                            Or is this bit of script just pants?

                            !!< | 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[ 2 ]='Text 3';
                            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


                              #15
                              For a start you don't have an opening <script ....> tag in there.


                              Bikster
                              SellerDeck Designs and Responsive Themes

                              Comment

                              Working...
                              X