• Hi,

    I'm working on a new design for my website and want a random pano on the top of my site, this is what i have so far...

    http://www.ronaldtichelaar.nl/toppano/


    After searching forums for to days and experimenting with java i give up. So my question is as follows...

    I want the pano in the frame to change after a pageload by loading a random xml or jpg file. Can this be done in javascript, AS3 or another programming language? What is the best way?

    Best,
    Ronald Tichelaar

  • Hi,

    great site!
    but you shouldn't use the name "banner" for the directory,
    my add-blocker (Adblock Plus, Firefox) blocked it

    changing the pano randomly every refresh can be done very easily with javascript (one line of code),

    for example - let's assume you have 4 panos, named:
    top1.xml
    top2.xml
    top3.xml
    top4.xml

    to choose one of them randomly: (code for your site)

    best,
    Klaus

  • OK, I'm finished and it is working. I've modified your script to pick 20 xml files and modified the random formula.


    for 4 xml files...

    Code
    var random_xml =  "top" + (1+Math.ceil(Math.random()*3)) + ".xml";


    This way it seemed like it would never pick 1.xml so I changed it to...

    Code
    var random_xml = "top" + (Math.ceil(Math.random()*4)) + ".xml";


    After some reloads this looked better. Could this modification cause other problems?


    Thanks again.
    Ronald

  • you're right,

    sorry, I mixed up "ceil" (rounding up) and "floor" (rounding down)

    so you can use:

    Code
    var random_xml =  "top" + (1+Math.floor(Math.random()*3)) + ".xml";


    or:

    Code
    var random_xml =  "top" + (Math.ceil(Math.random()*4)) + ".xml";

    BTW - absolutely great panos!

    regards,
    Klaus

  • Hi guys !
    I'm upping this thread cause I try to do something similar, but with the creatpanoviewer isdevice method.
    For now on I did a php script using the php rand but I have troubles in the iPhone, it's loading both iPhone and Android tour within the same page.
    Maybe there'll be another way doing this ?
    Here's my code :

    Thanks in advance and hoping this could help some of you ^^

  • Hi again ^^
    I've changed the PHP script and by the way I messed up in the loading script, the following resolves it :

    Cheers !!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!