Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mikkel 2 posts 20 karma points
    Mar 05, 2009 @ 11:48
    mikkel
    0

    JavaScript in Macro

    Hello!

    I'm fairly new to xslt, and I am trying to embed a piece of JavaScript in a macro. However i doen't seem to work for me. Since I'm new to this, the error is probably obvious, so any help will be appreciated!

    [code]
    ]>

    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">






  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 05, 2009 @ 15:12
    Ismail Mayat
    0

    mikkel,

    Can you post the actual script tags with content to see what the issue is.

    Thanks

    Ismail

  • mikkel 2 posts 20 karma points
    Mar 05, 2009 @ 16:03
    mikkel
    0

    Sure!

    Here the JS.
    [code]

    <script language="JavaScript"><br />
    <br />
    <!-- Begin JS Script --><br />
    <br />
    <!-- Begin<br />
    // Set up the image files to be used.<br />
    var theImages = new Array() // do not change this<br />
    // To add more image files, continue with the<br />
    // pattern below, adding to the array.<br />
    <br />
    theImages[0] = 'http://www.iord.dk/f1.jpg'<br />
    theImages[1] = 'http://www.iord.dk/f2.jpg'<br />
    theImages[2] = 'http://www.iord.dk/f3.jpg'<br />
    theImages[3] = 'http://www.iord.dk/f4.jpg'<br />
    <br />
    var j = 0<br />
    var p = theImages.length;<br />
    var preBuffer = new Array()<br />
    for (i = 0; i &lt; p; i++){<br />
       preBuffer[i] = new Image()<br />
       preBuffer[i].src = theImages[i]<br />
    }<br />
    var whichImage = Math.round(Math.random()*(p-1));<br />
    function showImage(){<br />
    document.write('<img src="'+theImages[whichImage]+'">');<br />
    }<br />
    <br />
    //  End --><br />
    </script>

    [/code]

  • rorythecheese 110 posts 56 karma points
    Mar 05, 2009 @ 17:08
    rorythecheese
    0

    Sometimes weird stuff happens with angle brackets <> and embedded javascript . You might be able to wrap in a or you might have to decode all the angle brackets to < > then put inside a .. but is not ideal.

  • Petr Snobelt 923 posts 1535 karma points
    Mar 05, 2009 @ 17:51
Please Sign in or register to post replies

Write your reply to:

Draft