close panorama

krpano Javascript Interface Version

During embedding the krpano viewer into the HTML page an Identification Name (ID) will be specified. The default ID is "krpanoSWFObject".

Link: See here for the id parameter: Embedding into HTML.

After embedding a HTML DOM Element with that ID will be created. This object can be get via the normal Javascript document.getElementById(id) function.

The krpano viewer exports these 3 Javascript functions to that object:
  • set(variable,value) - Sets any krpano variable to the given value.
  • get(variable) - Returns the value of any krpano variable.
  • call(action) - Calls and executes krpano action code.

Usage Example

Get the krpano HTML DOM Element:
var krpano = document.getElementById("krpanoSWFObject");

Get and set a variable:
var fov = Number( krpano.get("view.fov") );
fov += 10.0;
krpano.set("view.fov", fov);

Call a krpano action, e.g. to load an other pano."loadpano('pano2.xml',null,MERGE,BLEND(1));");


These examples were also included in the krpano viewer download package in the folder "examples/javascript-interface/".

  • loadpano() Example
    Shows how to call krpano and load other panos on Javascript clicks.
  • Mouse Position Example
    Get and show the current mouse position in pixels and spherical coordinates.
  • Get Link Example
    Get a link to the current Pano and the current view.
  • Sync Example
    Syncing two krpano viewers via Javascript.
  • Splitscreen Example
    Syncing two krpano viewers via Javascript and use different viewing areas to simulate a splitscreen.