David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

using input to open url page inside a html component

Hi,
im trying to open a webpage inside a html component, using a input as the websites url but i cant get the variable to work. this is what i have in the component at the moment

script language="javascript" type="text/javascript"

Code: Select all

var scrt_var = Appery ('urlpage').val();  

/script
iframe src=scrt_var; width="100%" height="100%" /iframe

but it doesnt see the variable just "scrt_var" as the url

please help

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

using input to open url page inside a html component

Hi David,

Please use the following code:prewindow.top.location = Apperyio('urlpage').val();/pre

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

using input to open url page inside a html component

Hi,

sorry to be a pain but how does this fit into the script i already have, does it need to replace anything. ive tried it and it keeps crashng the test

thank you for your help

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

using input to open url page inside a html component

Hi David,

You code seems to be broken(with site escaping).

But here is easy solution for you:

1 Put HTML component on the page. http://prntscr.com/4q2ylg/direct

2 Set "auto" and "auto" dimensions for HTML component.

3 Open this component properties and set following HTML:

pre

<iframe id="iframeForExternalSite"</iframe

/pre

3 Now you can use following JS code to set certain URL in this iframe stored in some input component:

pre

var inputUrlvalue = Apperyio("inputComponentName")&#46;val()&#46;trim();
jQuery("#iframeForExternalSite")&#46;attr("src", inputUrlvalue);

/pre

That's all.

Regards.

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

using input to open url page inside a html component

Hi,
Thanks for the help, but im still struggling to get it to work.
does the js code go in the html box event launch or in the html box in the script<. also does "src" need changing (at present ive only changed "inputComponentName")

thank you

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

using input to open url page inside a html component

Hi David,

Given JS code you can use on any event that's triggered after pager load.

For example - on button click event handler.

Also, you can add this code on "page show" if your input has value from app start.

Regards.

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

using input to open url page inside a html component

brilliant, thank you its working now

Return to “Issues”