defining the scenetoload in html

  • In index.htm I have the following code:


    <script>

    var viewer = createPanoViewer({swf:"krpano.swf", id:"krpanoSWFObject", target:"krpanoDIV"});

    //viewer.useHTML5("whenpossible"); // incomment to use the HTML5 krpanoJS viewer always when possible (Safari5)

    if( viewer.isDevice("iPhone|Android") )
    viewer.addVariable("xml", "xml/iphone-android.xml");
    else
    if( viewer.isDevice("iPad") )
    viewer.addVariable("xml", "xml/ipad.xml");
    else
    viewer.addVariable("xml", "xml/pc.xml");
    viewer.passQueryParameters();
    viewer.embed();


    </script>


    So I can call index.htm and specify which scene to open with, ie


    index.htm?scenetoload=pano5


    My question, how (and where) do I set in the index.htm that scenetoload=pano5. I could call from another html file and specify but I need to set up a number of html files which will be identical but each load a different scene.


    Thanks in advance


    Tim

  • Hi,

    the 'passQueryParameters' call will passen the given parameters from the html file to the viewer,

    e.g. instead of:

    Code
    index.htm?scenetoload=pano5


    and

    Code
    viewer.passQueryParameters();

    you could do also:

    Code
    viewer.addVariable("scenetoload", "pano5 ");

    and when doing that you will have a variable called 'scenetoload' in the krpano xml,
    so in the xml you can use them to load the right scene,

    e.g. do this check in the onstart event or an action that was called from there:

    Code
    if(scenetoload !== null, 
      <!-- the scenetoload variable is set, so load the given scene -->
      loadscene(get(scenetoload),null,MERGE);
     ,
      <!-- else load the default first scene -->
      loadscene(get(scene[0].name),null,MERGE);
    );

    best regards,
    Klaus

Participate now!

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