#1 2016-09-04 09:11:51

Kasito
Banned
Registered: 2016-08-05
Posts: 58

How do i Load url to an Iframe using Variable

Hi guys im trying out an app, which i intend to select a subject from a drop down menu.  then load a particular link address if the subject is english or mathematics.

(1)  page 1
the user select the subject    - i have done this

(2) page 2 - onShow
the selected option to load the appropriate link to iframe1   -  not yet done

EXAMPLE

if "subject.value" "==" english" 
    iframe1.load "[url=http://www.example.com/english.php]www.example.com/english.php[/url]"

elseif "subject.value" "==" mathematics" 
     iframe1.load "[url=http://www.example.com/english.php]www.example.com/english.php[/url]"

endif

Thanks the your anticipated cooperation with example.

Last edited by Kasito (2016-09-04 09:16:49)

Offline

#2 2016-09-04 09:19:08

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

You can take a look at the "DropDown" app sample. We must access to the "DropDown" control's "Items" variable using their "ItemIndex", for example, in the below code "Button1" is a DropDown control, and that code is placed in the DropDown's "ItemClick" event:

ArrayGetItem "[Button1.Items]" "[Button1.ItemIndex]" "[SelectedItem]"

AlertBox "You choose: [SelectedItem]" "info"

As you can see, using the DropDown's "Items" and "ItemIndex" variables we can get the clicked item in the DropDown control. Once we have the selected item we can proceed with your control code:

If "[SelectedItem]" "==" "english"
  // Do the job
EndIf

Offline

#3 2016-09-04 09:30:02

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Hi david

How do i do the Job specifically to an iframe1.  that is load the link into the iframe with your example below.

pls. give me proper example like below. 

If "[SelectedItem]" "==" "english"
  // iframe1.load "www.example.com/english

elseIf "[SelectedItem]" "==" "mathematics"
  // iframe1.load "www.example.com/mathematics

EndIf

The code is the be placed on the OnShow of the iframe1 page


Thanks

Last edited by Kasito (2016-09-04 09:31:43)

Offline

#4 2016-09-04 09:32:26

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

To load an URL into an IFrame control we must set the IFrame's "Url" variable:

SetVar "[iframe1.Url]" "http://www.example.com/english" "String"

Offline

#5 2016-09-04 10:26:47

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Thanks i think this will solve my issue but let me try and get back to you.  this is what i will do...

If "[SelectedItem]" "==" "english"
 SetVar "[iframe1.Url]" "http://www.example.com/english" "String"

elseIf "[SelectedItem]" "==" "mathematics"
  SetVar "[iframe1.Url]" "http://www.example.com/mathematics" "String"

EndIf

and will be placed on the page onShow to  target iframe1  for example if the user select any of the option in the drop down menu which will be in the previous page.  I am doing this because i believe all variables are global.

Thanks

Offline

#6 2016-09-04 10:29:37

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

Certainly app's variables are more or less globals (they are globals to the application) and your code appear correct. So please, post here if you have any further question or problem.

Offline

#7 2016-09-04 10:56:59

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Hi David

I have tried it but got a blank page.  can i in the Iframe Properties Source dialog paste the variable like this...

"[IFrame1.Url]"

which iam think will then load the appropriate value into the iframe or what do u think..

Last edited by Kasito (2016-09-04 10:57:49)

Offline

#8 2016-09-04 11:10:33

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

Talking about frames, we must assert we have the appropiate permissions to load certain URL in the IFrame. Certainly some external sites can disallow that, so please folow these instructions:

1º Run the application in the AB debugger

2º Open the application in the Firefox browser (or Chrome, or Edge)

3º Open the opened browser's console (press F12) and refresh the app's page

4º Look at the console for some possible error message...

If you have permissions problems, you must assert the website or URL that you want to load into the URL allows something like that.

Offline

#9 2016-09-05 01:34:12

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Hi David

I have followed your instruction and still not loading the iframe rather showing blank page,  then when i copied [IFrame1.Url] into the iframe url source in properties dialogue by found on the right hand side, then when in build and run the project it redirects me to undefined page.  this is the final code;

If "[SelectedItem]" "==" "english"
 SetVar "[iframe1.Url]" "[url]http://www.example.com/english[/url]" "String"

elseIf "[SelectedItem]" "==" "mathematics"
  SetVar "[iframe1.Url]" "[url]http://www.example.com/mathematics[/url]" "String"

EndIf

placed in the page show, the same page which the iframe resides.  one thing i noticed after implimenting this code is that, the index.html is reading "error copying index" during build.

Or where can in placed this code to load the url into the IFrame Control?

Last edited by Kasito (2016-09-05 01:39:01)

Offline

#10 2016-09-05 17:18:21

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

Please, note my previous post contains some instructions to find the possible problem: we expect the "white page", but maybe the Firefox's Developer Console can offer more information about the problem. Probaly this is related with a security issue, at least this is the common problem with IFrames.

Can you provide me (maybe in private) with the URL you want to shown in the IFrame?

Can you provide me with a little application sample in which I can reproduce the problem?

Offline

#11 2016-09-06 16:25:27

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

I'm ok now,  issue is resolved thanks.   I think I'm just getting to understand the concept of AB.   Now pages are loading like Cham. 

My only issue now is how the app can check if internet exist before loading  the page as provided above.

Many thanks.

Offline

#12 2016-09-06 16:38:35

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

Kasito wrote:

I'm ok now,  issue is resolved thanks.   I think I'm just getting to understand the concept of AB.   Now pages are loading like Cham. 

My only issue now is how the app can check if internet exist before loading  the page as provided above.

Many thanks.

Glad to know you solve it. Maybe you enable the appropiate permissions in the external website? Anyway, about how to check if an internet connection exists, take a look at the description of the "[App.Online]" variable. On the other hand, maybe you can also made some HTTP call to your app's server, and, just wait the response: if they exists you have internet connection, if the HTTP call fail you can asume the internet connection is not available.

Offline

#13 2016-09-06 17:06:24

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Is there any example on App.online ?  The examples are really helping me here, as novis.

Offline

#14 2016-09-06 17:10:26

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

I can't remember one sample about this (from the 133 already included) and I have no time right now (since I am working in another important issue on App Builder) so, can you try with the refered information? If you found some specific problem tell me and I will try to help you. On the other hand, maybe I can prepare a sample for this in the near future.

P.D. If you use the HTTP call the things is more or less easy: you use an HTTP Client control to perform an HTTP call. If the server respond in the right way, you can consider your application online. If the server did not respond... then you can consider your application "offline". If you decide to use the "GetNetworkType" action in a Cordova's build app, then I think there is suitate by default... so you only need to use that action and no more. But probably the HTTP call can be better...

Offline

#15 2016-09-06 18:29:03

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Ok. But I don't know what the responds will be?  Maybe   1 or 0 , true or false. ,  null or ...

If I know what value will be returned in the httpClient control it will be very easy to implement.   In the other hand I also considering App.Online. In this form

If "App.Online" "==" "true"
//Do the action

ElseIf "App.Online" "==" "false"
AlertBox "No internet found" "danger"
EndIf

This is just to help me verify if the app network state.  Since I am developing for Cordova.

Last edited by Kasito (2016-09-06 18:29:45)

Offline

#16 2016-09-06 18:31:29

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

If you perform an HTTP call using an HttpClient control and everything is fine (the server respond) then the HttpClient's Success event is fired. So you know there is an internet connection. On the other hand, if the HTTP call cannot be performed, the HttpClient's Error event is fired. And so you know there is not an internet connection.

The problem with "[App.Online]" variable is they are some differnet between browsers vendors. If you plain, however, to deploy your application as a Cordova's build application, then you can use the "GetNetworkType" action.

Offline

#17 2016-09-07 08:03:54

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Hi David I have got it working.  I used the get network type which works well.

Many thanks, I'm really understanding the AB concept.

Offline

#18 2016-09-07 08:25:34

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

Kasito wrote:

Hi David I have got it working.  I used the get network type which works well.

Many thanks, I'm really understanding the AB concept.

Glad to know! Thanks for your kindly words. Please, Kasito, consider to purchase one or more AB licenses if you find the program useful for you and your projects! wink

Offline

#19 2016-09-07 09:03:46

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do i Load url to an Iframe using Variable

Yes, I will. Once dollar drops from 380 which is the current rate per dollar in my country.  Was recently 160.  The rate will come down but no body knows when.  I'm learning AB because I will need it for my projects.   I have been converting HTML to APK which works great.  But AB is working smarter and better, so I will need it for sure permanently. For now I will continue to learn.

Many thanks for your projects and support.

Offline

#20 2016-09-07 09:08:11

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do i Load url to an Iframe using Variable

Hello Kasito,

Kasito wrote:

Yes, I will. Once dollar drops from 380 which is the current rate per dollar in my country.  Was recently 160.  The rate will come down but no body knows when.  I'm learning AB because I will need it for my projects.   I have been converting HTML to APK which works great.  But AB is working smarter and better, so I will need it for sure permanently. For now I will continue to learn.

Many thanks for your projects and support.

Thanks in advance sir. If you can feel better with a particular discount for you... just contact me in any moment and I will provide you that discount. So we can drop down the dollar rate, ok? smile

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.