Support » Plugin: Code Snippets » Convert HTML Script to Shortcode

  • I want to convert this code into a shortcode, I have seen that an example comes but when I put it it does not work. How can this script be converted into a shortcode from code snippets?

    <script>
     
    	rnd.today=new Date();
    	rnd.seed=rnd.today.getTime();
    
    	function rnd() {
            rnd.seed = (rnd.seed*9301+49297) % 233280;
            return rnd.seed/(233280.0);
    	}
    
    	function rand(number) {
    		var result = Math.floor(rnd() * number);
    		if (!result) result = 0;
    		return result
    	}
    	var bannerimgs = new Array("a.jpg", "b.jpg");
    	var bannerlnks = new Array("a.com", "b.com");
    	var banneralt = new Array("a", "b");
    	var rotatorHtml = "";
    	var endJs = "";
    
    	for(var img in bannerimgs){
    		var thisImg = new Image();
    		thisImg.src = bannerimgs[img];
    	}
    	var bannerimgCt = 2;
    	var bannercurrentAd = rand(bannerimgCt);
    	var openlink = "";
    	var bannerbanner = document.getElementById('banner');
    	var bannerlink = document.getElementById('banneradLink');
    	
    		if(bannerlnks[bannercurrentAd] != ""){
    		rotatorHtml += '<a href="' + bannerlnks[bannercurrentAd] + '" id="banneradLink"  target="_blank">';
    		endJs = "</a>";
    	}
    	rotatorHtml += '<img src="' + bannerimgs[bannercurrentAd] + '" alt = "' + banneralt[bannercurrentAd] + '" id="bannerbanner">' + endJs;
    	document.getElementById("banner_div").innerHTML = rotatorHtml;	
    </script>
    • This topic was modified 10 months, 2 weeks ago by xscorpionx.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.