Sie sind nicht angemeldet.

1

Mittwoch, 15. April 2015, 10:48

getting javascript value into hotspot attribute

hi
I want to put a value of a javascript function to a hotspot attribute. And I'm not really into javascript...
I've tried something like this:

<hotspot .... ath="js(azi());" .../>

and a function:
function azi()
{
alert("50");
}

but that's not working...what am I doing wrong?

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Muxi« (15. April 2015, 16:49)


Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

2

Mittwoch, 15. April 2015, 21:43

You can only run code in the onloaded, ondown, onclick etc.

I would try something like
onloaded="js(azi(name))"

function azi(name) {
krpano.call('set(hotspot['+name+'].ath,50)';
}

correct for syntax errors of course.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

3

Donnerstag, 16. April 2015, 09:47

thanks, I already got that I can't call anything from within an attribute...and tried with onloaded.
I played around with your hint, but I can't get the ath-value set by javascript.
I tried and other similar things, but without success.

Quellcode

1
2
3
4
5
6
function sun_az()
{
var krpano=document.getElementById ("krpanoSWFObject");
krpano.call("set(hotspot[spot1].ath,150");

}

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

4

Donnerstag, 16. April 2015, 16:27

You can place var krpano=document.getElementById ("krpanoSWFObject"); after your embed call in javascript. No need to redefine it.

First learn to effectively troubleshoot.
1. enable the javascript console in your browser.
2. run : krpano.call("showlog(true);");
3. If the log appears, then krpano is accepting javascript calls, if not, perhaps you created the wrong swf file with options, or var krpano=document.getElementById ("krpanoSWFObject"); matches the wrong ID.
4. Try krpano.call("set(hotspot[spot1].ath,150"); if that works then go back to working on your functions.
5. you can run the javascript straight from the console and your krpano commands wrapped in krpano.call("");

good luck!
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

5

Samstag, 18. April 2015, 23:51

wow, the javascript console is pretty cool *thumbup* thanks for the tip, now I got it working!