You are not logged in.

panoyun

Intermediate

  • "panoyun" started this thread

Posts: 234

Location: Somalia

  • Send private message

1

Friday, April 15th 2022, 3:52pm

layer[name].iframe how to use

Source code

1
2
3
4
5
6
7
8
9
10
11
12
	<layer name="layer_iframe"
       type="iframe"
       iframeurl="https://krpano.com/home/"
       align="center" width="800" height="600"
       keep="true"
       onloaded="add_iframe()"
       />

	<action name="add_iframe" type="Javascript"><![CDATA[
	layer[layer_iframe].iframe.style.width = "100%";
	layer[layer_iframe].iframe.style.height = "100%";
	]]></action>



layer[name].iframe how to use


*confused* *confused* *confused*

2

Saturday, April 16th 2022, 10:52am

Hi,

what do you want to do?

The add_iframe action code in your example is wrong (that's not valid JS code) and unnecessary.

Just this would be enough:

Source code

1
2
3
4
5
6
<layer name="layer_iframe"
       type="iframe"
       iframeurl="https://krpano.com/home/"
       align="center" width="800" height="600"
       keep="true"
       />


Best regards,
Klaus

panoyun

Intermediate

  • "panoyun" started this thread

Posts: 234

Location: Somalia

  • Send private message

3

Saturday, April 16th 2022, 12:07pm

onloaded="layer[name].iframe"
I haven't figured out how this is used?
what is his role

When the iframe is ready the onloaded event will be called and the layer will contain a iframe variable that provides access to the iframe html-element.

*confused*

4

Thursday, April 21st 2022, 4:30pm

Hi,

what are you trying to do?

There is no need to use an onloaded event and do there anything unless you want to do something specific there...
See my example above, that's all code that's needed.

Best regards,
Klaus

panoyun

Intermediate

  • "panoyun" started this thread

Posts: 234

Location: Somalia

  • Send private message

5

Thursday, April 21st 2022, 4:57pm

iframe.style.left = 0;
iframe.style.top = 0;
iframe.style.right = 0;
iframe.style.bottom = 0;
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.border = 0;
iframe.style.margin = "auto";

control parameters like this

6

Friday, April 22nd 2022, 4:46pm

Hi,

none of these parameters would need to be set... (and basic layout properties also shouldn't be changed)

Anyway to access the iframe element:
- call a Javascript function
- and access the iframe object by 'caller.iframe':

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<layer name="layer_iframe"
       type="iframe"
       iframeurl="https://krpano.com/home/"
       align="center" width="800" height="600"
       keep="true"
       onloaded="do_something_with_the_iframe()"
       />

<action name="do_something_with_the_iframe" type="Javascript"><![CDATA[
  var iframe = caller.iframe;
  iframe.style.XXX = YYY;
  ...
]]></action>


See also here about the 'caller' object:
https://krpano.com/docu/xml/#action.js

Btw - in your first post example you were trying to use 'layer[layer_iframe].iframe', but that syntax is 'krpano script' code and not Javascript code.

Best regards,
Klaus

panoyun

Intermediate

  • "panoyun" started this thread

Posts: 234

Location: Somalia

  • Send private message

7

Friday, April 22nd 2022, 4:54pm

Thanks for your detailed answer dear, I understan