- This topic has 28 replies, 4 voices, and was last updated 11 years, 2 months ago by support-michael.
-
AuthorPosts
-
jeremy450MemberHi there
is it possible to do the following
have a push button on the screen
and have the Javascript to set the on click action to URL and set the URL and Open URL in?
and how?
regards
Jeremy
TurgutGuneysuMemberHi Jeremy
Hope this helps:
Place a button on the screen.
Set its on-click action to ‘Run javascript’.
Paste the sample CODE below into the javascript window for the action.
set the URL the way you need it.
Gen and test.myURL = "http://www.google.com" ; // Initialize this any way you need // JQuery call to retrieve URL page jQuery.ajax({ url: myURL, // the type of data we expect back dataType : "html", // html, text, xml, json // code to run if the request is OK - Parse data here success: function(webText) { // Insert processing for received data here // webText will have the data // make sure the web site is sending data in the format specified in dataType console.log("We are in SUCCESS routine"); }, // END of SUCCESS // code to run if the request fails; the raw request and // status codes are passed to the function error: function( xhr, status ) { // Insert ERROR processing here console.log("We are in ERROR routine"); }, // END of ERROR // code to run AFTER success or failure complete: function( xhr, status ) { // Insert Final handling here console.log(' We are in FUNCTION COMPLETE routine" ); } // END of COMPLETE }); // END of JQuery Ajax
jeremy450MemberHi tguneysu
Thanks for the info. but what if I want to be able to change the address?
I have a screen where it grabs info from a xml on a site and populates a list
i’m trying to find a way where when you tap it it goes to the URL of that entry.
at the moment i’m able to push into to another screen when tapped, but no the goturl part
I want to be able to use the custom.js file and have it set the click event on a button or something and use the GoToURL part of the click event to a certain url that’s pulled from the xml file.
sorry if I didn’t explain it properly first time.
regards
Jeremy
TurgutGuneysuMemberJeremy,
mYURL in the code was just an example. You can set it any way you like in the custom.js or elsewhere.
Alternatively, if you want to use a form for example to send the URL requests, and set the URLs in code somewhere else, the code to set the URL in the form would be:
myURL = <set it from your XML data>
document.getElementById(“m1_yourFormName”).action=myURL;The command to send the form programmatically is:
phoneui.submitForm(“m1_yourFormName”);
By combining these you should be able to achieve what you need.
Look into the generated HTML and JS files to findout the exact field and form names to use.
TG
jeremy450MemberHi tguneysu
I fellowed your instructions and your code and it didn’t work when tested.
regards
Jeremy
support-michaelKeymasterIf you are using the MobiOne designer widgets it is simple and requires no javascript.
1) add a button to your design
2) assign the button’s OnClick property (see the Properties view) a Goto URL action. Fill in the URL you want to load. See attachment onclick-gotourl.pngAttachments:
You must be logged in to view attached files.
TurgutGuneysuMemberJeremy,
I have attached a small mobi program to demonstrate the concept.
This was done in MOBI2.3.2.
Runs fine in the Test Center of MOBI2.3.2.It uses a FORM to submit a default URL defined in the form: http://m.google.com
It displays the received result in the display area.There is a text field on the screen. If you fill it with a fully formed URL, then it will replace the one in the form with this new one. It will transmit and get the result and display it in the display area.
e.g.: you can enter: http://mobile.msn.com/ to get the msn mobile site.
Form Result Type is set to: Data-HTML (AJAX).
This will display the received HTML in the display area.If you change it to Web Page UI, then you get the actual web page display overlaying the entire program screen.
That might not be of much use, but it shows what web page you are getting.The code for the button handles swapping URLs. This can be placed into the custom.js if needed.
The code in the custom.js handles post transmit display of the data in the display area.
If you open the console area while you are testing, you will the console.log outputs from the program with form object details and changed URLs.
TG
Attachments:
You must be logged in to view attached files.
BrandonMemberAre you talking about something like this:
var myDynamicURL;
function gotoMyURL()
{
phoneui.showURL(myDynamicURL, “_blank”);
}Then in the buttons run javascript use the
gotoMyURL()now you can set the myDynamicURL to any url with code:
myDynamicURL = ‘http://genuitec.com’;
and it will open that url.
support-michaelKeymasterHi Jeremey,
I spent time reading through an email description of your UI flow and implementation request. I then reviewed the feedback provided on this thread. In a nutshell I don’t understand your textual description. Code snippets have been provided here that on the surface should move your rss reader implementation forward. But your feedback is that they don’t help you. Let me propose that you do the following:
An annotated picture for UI related problems is frequently worth 1000 words. Consider providing a mockup of the screen flow of your UI, i.e., a storyboard using mobione or scratch paper, anything visual. Add annotations that describe exactly what how data is mapped to the UI, how actions change the UI, etc. (request: do not post giant full screen images that are unwieldy to view… be user friendly.)
I understood your most recent request by email for how to load a remote web resource (URL) in the device’s browser from a button action of a mobione app. CincyPlanet’s snippet above is helpful for accomplishing this. You can attach an OnClick Run JavaScript action with a similar snippet and the URL you are seeking. Again there is probably a nuance to this that I’m missing that a storyboard can clarify.
Bug – I appreciate you sharing the URL to the pdf file you are seeking to load in the device browser. The URL contains hex codes for spaces which is legitimate. MobiOne 2.3 uses the Cordova/PhoneGap ChildBrowser plugin to implement the GotoURL action, also the phoneui.showUrl() api. On android there is special support for pdfs that involves downloading the pdf file to tmp location on the device and then opening it locally. From what I can tell the mobione phoneui framework is passing URLs that include hex encoded chars incorrectly causing the local pdf reader app to goof up. I opened a bug for our team to eval and see if we can get a fix in for this. A quick workaround for this if you have control over the path the pdf is located, move the pdf file such that the URL contains on spaces or other chars that require escaping.
jeremy450Memberi dont want to sound rude but i’m really starting to get frustrated here.
this is the email i sent to support with subject mobione project data jeremy450:
Hi there
thank you for looking at this. i’ll explain to you what i’m trying to do
i’ve included part of my app that i’m having trouble with.
what i’m trying to do is when the person clicks on newsletters it loads the list of newsletters which is doing(by the way thank you for the RSS example it was great i used it in this app) as you will see. but i’m trying to do is when the person taps on the newsletter to read it, the tap will do a GoToURL event which opens the OS browser and loads the newsletter.
currently i cant get it to load the newsletter in the html window in the newsletterform as android doesnt know to run the PDF Reader and also it would make it more compatible with IOS as well as IOS(I thank) would recolonize the GoToURL like it does with the push buttons, etc.
in the mains_custom.js in var con2 is the one i want to use for the GoToURL event.
i hope i’m right on what i said about IOS.
i’m trying to make this app for both IOS and android
Thank you so much for you RSS Example and also for your help with this.
I really do want to buy this program but i want to be sure this is possible before purchasing it.
regards
Jeremyi Cant attach the file as it exceed your limit on here but here is the link
http://www.jemisp.com/project/project.zipIn a nutshell all i’m trying to do is open a PDF from a list of PDF files that is grabbed from a xml file from a site. And needs to work with both Android and IOS. So far i had no success with open PDFs with using the built in browser. They open when the link is typed into the OS Browser. When you look at my project you will se i’ve done practical most of the work. its just this one point i’m having troubles with. The project works. just not opening the PDF sides of things. I’m not good with java scripting, mobione. i’ve biult complex ASP,PHP,VB, and Windows phone apps but this i cant get my head around it
BrandonMemberOk, from what I read and have seen trhis:
On your newsletter list page set the javascript action to instead of the newsletter mobi file.:
phoneui.showURL(con2, “_blank”);
Importrant: Make sure your variable con2 is declared outside of the function, if its declared inside it wont be available globally. Right now it is inside the viewnewsletters() function,
support-michaelKeymasterI tested a newsletter pdf url shared yesterday that includes hex encoded spaces. MobiOne 2.5M1 and earlier have issue with such urls on android. We have a fix in the works today. The fix will be available in 2.5M2 planned early next week once we finish up some final improvements and complete testing. I’ll post a note back here as soon as we confirm the fix and can make it available.
jeremy450MemberHi CincyPlanet
how and where would i declare it?
regards
Jeremy
BrandonMemberTry declaring it just before the function:
Currently this is what you have:
function viewnewsletters() {
var selItem = $(event.srcElement).closest(‘li[data-listitem-index]’);
var itemId = $(selItem).attr(“data-listitem-index”);
var list_items = $(“:root”).data(“newsletters”);
var item = list_items[itemId];
var title = item[“title”];
var desc = item[“desc”];
var cont = item[“content”];
var cont2 = item[“content2”];
var daydate = item[“daydate”];
var monthdate = item[“monthdate”];
…
}change it to this:
var cont2;
function viewnewsletters() {
var selItem = $(event.srcElement).closest(‘li[data-listitem-index]’);
var itemId = $(selItem).attr(“data-listitem-index”);
var list_items = $(“:root”).data(“newsletters”);
var item = list_items[itemId];
var title = item[“title”];
var desc = item[“desc”];
var cont = item[“content”];cont2 = item[“content2”]; //<—–the changed one
var daydate = item[“daydate”];
var monthdate = item[“monthdate”];
…
}This assumes that in the data feed the cont2 is the URL you want to use.
NOTE: I had to take out a couple lines due to the forum does not like when you post percent signs.
jeremy450Memberhi CincyPlanet
i tried what you said with no luck. The con2 does work with no issues but it wont do the
phoneui.showURL(con2, “_blank”); in the run javascriptwith no luck.
regards
Jeremy -
AuthorPosts