Hi nelk,
Yes, there is a way to do using javascript to retrieve a variable from the URL...
Ex: YourDomain.com/PanoTour
?pano=panoToBeLoaded
I have used, as the base to illustrate the following, the
scene example that come with Krpano_1.0.8 download.
In the
scene.xml example, there is an
action(onstart) called by the Krpano.
onstart argument...
The
action(onstart) is as follow:
|
Source code
|
1
2
3
|
<action name="onstart">
loadscene(scene1, null, MERGE);
</action>
|
This action loads the scene to be loaded...
Then, using a javascript that retrieve the variable
pano from the URL
, in the
scene.html file we go to change dynamically the
content of this action with the scene we need to be loaded.
Like this:
so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");
The resulting
scene.html file will be:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<html>
<head>
<title>krpano.com scenes example</title>
<script type="text/javascript">
pano = "scene1"; // Default pano to be loaded if not set in the URL
searchVariables = location.search.substring(1,location.search.length);
if (searchVariables!="") {
arrVariables = searchVariables.split("&");
for (i=0; i<arrVariables.length; i++) {
arrVariableActual = arrVariables[i].split("=");
if (isNaN(parseFloat(arrVariableActual[1])))
eval(arrVariableActual[0]+"='"+unescape(arrVariableActual[1])+"';");
else
eval(arrVariableActual[0]+"="+arrVariableActual[1]+";");
}
}
</script>
</head>
<style>
body{ font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#FFFFFF; background-color:#000000; margin:0; padding:0; }
* html, * html body{ overflow: hidden; }
a{ color:#AAAAAA; text-decoration:underline; }
a:hover{ color:#FFFFFF; text-decoration:underline; }
</style>
<body>
<div id="krpanoDIV">
<noscript><table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br/><br/>Javascript not activated<br/><b/r></center></td></tr></table></noscript>
</div>
<script type="text/javascript" src="../../swfobject/swfobject.js"></script>
<script type="text/javascript" src="../../swfobject/swfkrpanomousewheel.js"></script>
<script type="text/javascript">
// <![CDATA[
if (typeof(deconcept) !== 'undefined')
{
if (deconcept.SWFObjectUtil.getPlayerVersion().major >= 9)
{
var so = new SWFObject("../../krpano.swf","krpanoSWFObject","100%","100%","9.0.28","#000000");
so.addParam("allowFullScreen","true");
so.addVariable("xml", "scenes.xml");
so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");
if (so.write("krpanoDIV")) { var mousewheelfixes = new SWFkrpanoMouseWheel(so); }
}
else
{
document.getElementById("krpanoDIV").innerHTML = '<table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br><br>Adobe Flash Player 9 needed<br><br><br><a href="http://www.adobe.com/go/getflashplayer/" target="_blank"><IMG SRC="http://www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" BORDER="1"></a><br>...click here to download...<br><br><br><br></center></td></tr></table>';
}
}
else
{
document.getElementById("krpanoDIV").innerHTML = '<table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br/><br/>swfobject.js not found<br/><br/></center></td></tr></table>';
}
// ]]>
</script>
</body>
</html>
|
Lines 5 to 18 are the javascript code that retrieve the variables from the URL...
Note the line 6.... here you set the default value to the variable
pano if it is not set on the URL.
Line 47... this is the line that change the
action[onstart].content
That's all.
note: this thread
Banner without XML has helped me to get this code.
Salut.