You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, September 19th 2016, 4:47pm

EDITED: openurl get url string at runtime?

Hi,
I'm trying to open a link using openurl, but why openurl(get(link)) open a empty page, and openurl(get(link2)) can open www.google.com correctly? am I wrong? or it's a bug?

set(link,'http://www.google.com');
set(link2,get(link));

set(hotspot[demo].onclick,
openurl(get(link));
<!-- openurl(get(link2)); -->
);

__________________________________________________________________________
EDITED:

I tested in a simple demo and found the regular pattern, my 'link' variable was in a loop, so the value change every time. I use the code below to simulation:


set(link,"http://www.google.com");

set(hotspot[test].onclick, openurl(get(link)));

set(link,"http://www.facebook.com");


It opened the facebook not google.

So is the openurl action get the url string at runtime? not at the bind time?
If I will use different url in a loop, I have to use textadd to join string?



This post has been edited 5 times, last edit by "jove" (Sep 22nd 2016, 3:32pm)


spacerywirtualne

Professional

Posts: 866

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

2

Monday, September 19th 2016, 8:40pm

Hi

you skipped )


set(hotspot[demo].onclick,openurl(get(link)));


Piotr
You own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: facebook group :: youtube

cms4vr team *thumbsup*

3

Tuesday, September 20th 2016, 3:55am

I edited the code in order to see it clearly. I just commented the openurl(get(link2)); to test openurl(get(link));, but it open a empty page, if I commented the openurl(get(link));, it will open the right page.

spacerywirtualne

Professional

Posts: 866

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

4

Tuesday, September 20th 2016, 8:40am

If you trace link2 then what you get?


Source code

1
trace('link: ',get(link),' link2: ',get(link2));


Piotr
You own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: facebook group :: youtube

cms4vr team *thumbsup*

5

Tuesday, September 20th 2016, 4:08pm

It shows all the same, the "www.google.com"
but
openurl(get(link)); just open a empty page.

Alexey Tkachenko

Professional

Posts: 737

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

6

Wednesday, September 21st 2016, 8:52am

Hi!

You use get(); incorrectly in this case. Replace

Source code

1
set(hotspot[spot1].onclick, openurl(get(link)); );



with

Source code

1
txtadd(hotspot[spot1].onclick, 'openurl(', get(link),');');
Regards,

Alexey

7

Wednesday, September 21st 2016, 2:29pm

Thanks, but why openurl(get(link2)); can open the right page without txtadd?

Alexey Tkachenko

Professional

Posts: 737

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

8

Wednesday, September 21st 2016, 2:52pm

That's because in this case it tries to open url 'get(link)'. That is, 'get(link)' is perceived like a string (text) here and so get() doesn't resolve 'link' variable.

EDIT: now I read your post more carefully and it's really strange. Need to find out. ;-)
Regards,

Alexey

Alexey Tkachenko

Professional

Posts: 737

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

9

Wednesday, September 21st 2016, 3:13pm

Made a quick test and it seems I was wrong. This code works fine (Win 7, Chrome Web GL):

Source code

1
2
set(link,'http://www.google.com');		set(link2,get(link));
		set(hotspot[spot1].onclick, openurl(get(link)););



No need for txtadd then.
Regards,

Alexey

10

Thursday, September 22nd 2016, 6:40pm

Please post a link to the FULL example!

11

Friday, September 23rd 2016, 6:34pm

here is the example:
#mce_temp_url#

12

Sunday, September 25th 2016, 5:52pm

Hi,

there is no variable binding.

The onclick attribute itself only contains text and that text-content will be resolved and executed when the event itself will be called.

So the 'link' variable would be resolved to that value that it has at the event calling time.

Therefore the 'txtadd' solution would be the correct one for your case:

Source code

1
txtadd(hotspot[spot1].onclick, 'openurl(', get(link),');');
Here the 'link' variable will be resolved to its value when setting the onclick event code.

Btw - an alternative syntax would be also possible by using calc:

Source code

1
set(hotspot[spot1].onclick, calc('openurl(' + link + ');'));
or:

Source code

1
calc(hotspot[spot1].onclick, 'openurl(' + link + ');');
The result of these 3 calls will be always the same.

Best regards,
Klaus

13

Monday, September 26th 2016, 2:56am

Thanks klaus, now I understand very clearly :)

14

Monday, June 25th 2018, 5:46pm

hello, i would like to know why when i don't put "http://" on my link it doesn't work... the link looks like...

/myfolder1/mysubfolder/www.mylink.com

and if i put http:// before the link it's work well...