You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, May 13th 2012, 7:46pm

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

2

Monday, May 14th 2012, 12:15pm

Hi,

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

e.g. instead of:

Source code

1
index.htm?scenetoload=pano5 

and

Source code

1
viewer.passQueryParameters(); 


you could do also:

Source code

1
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:

Source code

1
2
3
4
5
6
7
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

3

Monday, May 14th 2012, 1:59pm

Thats great, all working fine.

Thanks Klaus for the quick response.

cheers

Tim