You are not logged in.

1

Wednesday, April 15th 2020, 1:07pm

How can I get Placeholder variable values through js?

Hi,
I want to access placeholder variables from js, such as %HTMLPATH%, %SWFPATH%, %CURRENTXML%,
I tried like below, however, none of them works:


document.getElementById('krpanoSWFObject').get('%SWFPATH%')

document.getElementById('krpanoSWFObject').get('SWFPATH')


document.getElementById('krpanoSWFObject').get('%$SWFPATH%')
Any ideas about how to access these variables?
Thanks
[list][/list]

2

Wednesday, April 15th 2020, 10:00pm

Some of these paths seem to be available as variables:
network.viewerpath
network.htmlpath
network.firstxmlpath
network.currentxmlpath

so ....get('network.firstxmlpath') should work.

3

Friday, April 24th 2020, 11:26am

Thank you very much

light_line

Intermediate

Posts: 169

Occupation: krpano freelancer || creating ideas & coding them || krpano developer

  • Send private message

4

Friday, April 24th 2020, 5:27pm

use can use this function in javascript:

Source code

1
2
3
4
5
6
7
8
9
10
11
    function fix_path(path){
		var network = krpano.get("global.network");
		path = path.replace(/\%BASEDIR\%/g, network.basepath);
		path = path.replace(/\%FIRSTXML\%/g, network.firstxmlpath);
		path = path.replace(/\%CURRENTXML\%/g, network.currentxmlpath);
		path = path.replace(/\%HTMLPATH\%/g, network.htmlpath);
		path = path.replace(/\%VIEWER\%/g, network.viewerpath);
		path = path.replace(/\%SWFPATH\%/g, network.viewerpath);
		path = path.replace(/\%ROOT\%/g, network.viewerpath);
		return path;
	}

5

Friday, April 24th 2020, 9:42pm

Hi,

for resolving the url placeholders you can also use the parsepath function:
https://krpano.com/docu/plugininterface/#parsepath

Best regards,
Klaus