luchofox Posted October 24, 2013 Share Posted October 24, 2013 Hi, im doing some changes on this module HTML Box, where i can insert html code. I have a sidebar banner, but the same is displayed on all the products page, i would like change this image for an image randomizer script. I've found this <script language="JavaScript"> <!-- function random_imglink(){ var myimages=new Array() myimages[1]="http://oxfordcreamery.com/wp-content/uploads/2013/04/Raspberry-Lime- Rickey1.png" myimages[2]="http://www.cnet.com/i/bto/20100318/hamBBlend_270x337.jpg" myimages[3]="http://www.darecipes.com/images/274.jpg" myimages[4]="http://blogs.denverpost.com/style/files/2013/04/toms-ikat-270x337.jpg" myimages[5]="http://poppiesandlilieslifestyle.files.wordpress.com/2011/01/crush-use- ii1.jpg" myimages[6]="http://news.cnet.com/i/bto/20090127/motorolatlkrt7_270x337.jpg" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<img src="'+myimages[ry]+'" border=0>') } random_imglink() //--> </script> On single HTML works perfect, but when i include this into HTML Box, nothing happens... Any idea why? or how must i insert this javascript into HTMLbox? Thank you in advance for your answers. Luis Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 you need to remove spaces from: var myimages=new Array() myimages[1]="http://oxfordcreamer...Raspberry-Lime- Rickey1.png" myimages[2]="http://www.cnet.com/...end_270x337.jpg" myimages[3]="http://www.darecipes.../images/274.jpg" myimages[4]="http://blogs.denverp...kat-270x337.jpg" myimages[5]="http://poppiesandlil...1/01/crush-use- ii1.jpg" myimages[6]="http://news.cnet.com...rt7_270x337.jpg" Link to comment Share on other sites More sharing options...
luchofox Posted October 24, 2013 Author Share Posted October 24, 2013 you need to remove spaces from: var myimages=new Array() myimages[1]="http://oxfordcreamer...Raspberry-Lime- Rickey1.png" myimages[2]="http://www.cnet.com/...end_270x337.jpg" myimages[3]="http://www.darecipes.../images/274.jpg" myimages[4]="http://blogs.denverp...kat-270x337.jpg" myimages[5]="http://poppiesandlil...1/01/crush-use- ii1.jpg" myimages[6]="http://news.cnet.com...rt7_270x337.jpg" Thanks again for your answer Vekia. I did, i removed spaces and reduced the number of images, now my script for testing looks: <script language="JavaScript"> <!-- function random_imglink(){ var myimages=new Array() myimages[1]="http://www.cnet.com/i/bto/20100318/hamBBlend_270x337.jpg" myimages[2]="http://www.darecipes.com/images/274.jpg" myimages[3]="http://news.cnet.com/i/bto/20090127/motorolatlkrt7_270x337.jpg" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<img src="'+myimages[ry]+'" border=0>') } random_imglink() //--> </script> But still without appear, im exactly using this script into HTMLbox... no results.... Any other idea...? Thanks Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 can you share url to your website please? i will inspect code there Link to comment Share on other sites More sharing options...
luchofox Posted October 24, 2013 Author Share Posted October 24, 2013 can you share url to your website please? i will inspect code there Thanks, please check http://goo.gl/3MReAi Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 you need to use also ";" att the eand of each non-function line as it is suggested for javascript syntax function random_imglink(){ var myimages=new Array(); myimages[1]="http://www.cnet.com/...end_270x337.jpg"; myimages[2]="http://www.darecipes.../images/274.jpg"; myimages[3]="http://news.cnet.com...rt7_270x337.jpg"; var ry=Math.floor(Math.random()*myimages.length); if (ry==0); ry=1; document.write('<img src="'+myimages[ry]+'" border=0>'); } random_imglink(); Link to comment Share on other sites More sharing options...
luchofox Posted October 25, 2013 Author Share Posted October 25, 2013 you need to use also ";" att the eand of each non-function line as it is suggested for javascript syntax function random_imglink(){ var myimages=new Array(); myimages[1]="http://www.cnet.com/...end_270x337.jpg"; myimages[2]="http://www.darecipes.../images/274.jpg"; myimages[3]="http://news.cnet.com...rt7_270x337.jpg"; var ry=Math.floor(Math.random()*myimages.length); if (ry==0); ry=1; document.write('<img src="'+myimages[ry]+'" border=0>'); } random_imglink(); Thanks for your advice but nothing happens! I dont know why the JS cant be executed ... ready to give up... Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 can you show how your code looks like right now? i will test it on my own store. Link to comment Share on other sites More sharing options...
luchofox Posted October 25, 2013 Author Share Posted October 25, 2013 can you show how your code looks like right now? i will test it on my own store. Sure, thanks. This is the code than i have into HTMLbox <script language="JavaScript"> function random_imglink(){ var myimages=new Array(); myimages[1]="http://kapconsulting.us/download/top-banner.jpg"; myimages[2]="http://kapconsulting.us/download/top-banner2.jpg"; myimages[3]="http://kapconsulting.us/download/top-banner3.jpg"; var ry=Math.floor(Math.random()*myimages.length); if (ry==0); ry=1; document.write('<img src="'+myimages[ry]+'" border=0>'); } random_imglink(); </script> Link to comment Share on other sites More sharing options...
vekia Posted October 26, 2013 Share Posted October 26, 2013 take a look here: http://demo.mypresta.eu/en/ scroll page down, right above footer. the same module, the same code. take a look on this test tool: http://codepen.io/hrbj/pen/jvqig the same output Link to comment Share on other sites More sharing options...
luchofox Posted October 26, 2013 Author Share Posted October 26, 2013 take a look here: http://demo.mypresta.eu/en/ scroll page down, right above footer. the same module, the same code. take a look on this test tool: http://codepen.io/hrbj/pen/jvqig the same output hmmmm... i see it works for you, could be a conflict with other prestashop module... could be. But.. random function doesnt work, right? i mean, in every reload always show only the red banner... do you see it? Link to comment Share on other sites More sharing options...
vekia Posted October 26, 2013 Share Posted October 26, 2013 yes random function doesnt work even on codepen (and on jsfiddle to) this mean that it isn't well coded in back office don't use tinymce editor, just simple HTML editor. Link to comment Share on other sites More sharing options...
luchofox Posted October 26, 2013 Author Share Posted October 26, 2013 take a look here: http://demo.mypresta.eu/en/ scroll page down, right above footer. the same module, the same code. take a look on this test tool: http://codepen.io/hrbj/pen/jvqig the same output Hi Vekia, Finally works! i used another javascript and it works with your HTMLbox module. Works perfect! Thank you for your constant support. Best regards! LuchoFox Link to comment Share on other sites More sharing options...
vekia Posted October 26, 2013 Share Posted October 26, 2013 glad to hear that it works for you! may i know something more about code that you're using right now? im so curious because idea about this "rotated" image banner is very good i marked this thread as [solved] with regards, Milos Link to comment Share on other sites More sharing options...
luchofox Posted October 26, 2013 Author Share Posted October 26, 2013 glad to hear that it works for you! may i know something more about code that you're using right now? im so curious because idea about this "rotated" image banner is very good i marked this thread as [solved] with regards, Milos Looks it working: http://goo.gl/pJtSmc Could be a good module for a lot of people... needs a admin panel where update the images... eh? Include me on your testing users when you develope it! FINAL CODE: <script type="text/javascript"> var images = [], index = 0; images[0] = "<a href = '#'><img src='http://replacethisurl.com/imagen/today.jpg' alt=''></a>"; images[1] = "<a href = '#'><img src='http://replacethisurl.com/imagen/today2.jpg' alt=''></a>"; images[2] = "<a href = '#'><img src='http://replacethisurl.com/imagen/today3.jpg' alt=''></a>"; images[3] = "<a href = '#'><img src='http://replacethisurl.com/imagen/today4.jpg' alt=''></a>"; index = Math.floor(Math.random() * images.length); document.write(images[index]); </script> 1 Link to comment Share on other sites More sharing options...
vekia Posted October 26, 2013 Share Posted October 26, 2013 nice one and it is also with responsivene effect! brilliant Link to comment Share on other sites More sharing options...
luchofox Posted October 26, 2013 Author Share Posted October 26, 2013 nice one and it is also with responsivene effect! brilliant Yes looks good. Let me know if you create a module to admin this images from backoffice. Other stuff, please could you check this link and give me some idea..? http://www.prestashop.com/forums/topic/284576-add-a-counting-clock-on-header/ Thanks! LuchoFox Link to comment Share on other sites More sharing options...
chat2seagull Posted November 10, 2013 Share Posted November 10, 2013 Hi Vekia, I have downloaded html box and installed under modules. I would like to create popup window in home page and display message "website under development". Please advice how to create popup in html box Thanks Link to comment Share on other sites More sharing options...
vekia Posted November 10, 2013 Share Posted November 10, 2013 hello if i were you i will display it not in popup, but in modal window. Why? By default, all browsers block popups right now, so your customers will not see it, only after "approve popup" it will not be useful Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now