Page 1 of 1

using input to open url page inside a html component

Posted: Wed Sep 24, 2014 6:00 pm
by David wyatt

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


using input to open url page inside a html component

Posted: Wed Sep 24, 2014 8:09 pm
by Kateryna Grynko

Hi David,

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


using input to open url page inside a html component

Posted: Wed Sep 24, 2014 8:35 pm
by David wyatt

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


using input to open url page inside a html component

Posted: Thu Sep 25, 2014 4:46 am
by Yurii Orishchuk

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.


using input to open url page inside a html component

Posted: Thu Sep 25, 2014 10:53 am
by David wyatt

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


using input to open url page inside a html component

Posted: Fri Sep 26, 2014 3:05 am
by Yurii Orishchuk

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.


using input to open url page inside a html component

Posted: Fri Sep 26, 2014 8:48 am
by David wyatt

brilliant, thank you its working now