Once you purchase krpano with the Javascript License, the templates, default html are setup to do just this.
You can look at the examples provided in the viewer download package to see how the programming / xml works.
And check here.
http://krpano.com/docu/
Really, programming krpano or FPP are fairly similar but KRPano is about 3000% times more comprehensive / capable of much much more and no need for the type of plugins that FPP has to provide extra functionality due to its lack of the ability to use programming logic in the xml.