How to handle browser refresh while jqm-popup is open - jquery-mobile

I have a jquery mobile page, that uses a jqm-popup to display some content.
when the popup is opened, jqm appends a hash to the url: www.myjqm_page.com/#&ui-state=dialog.
Now if, while that popup is open, I refresh the browser, I get a broken site.
What is the proper way to handle this?

Related

browsing inside an iframe

I have a wordpress page that loads an
iframe prompting the user to navigate through bing to a webpage he/she wants. After browsing and upon arriving at the page the user wants he/she has to press a button to copy the current ulr to the clipboard or to print the url through alert() or on screen.
Question: is there a status attribute or something else that can give me the current status / metadata of the iframe (i.e. what page the iframe is visiting at a specific moment?). Thank you very much!
You cannot, it is forbidden to access any contents of an iframe that is not from your own domain, this is because of cross-site scripting restrictions.
You can read more about that here:
http://en.wikipedia.org/wiki/Cross-site_scripting
If you would be on the same domain however, you could do something like this in jQuery:
var url = document.frames['example-frame'].location.href;
when you would have an iframe like so:
<iframe name="example-frame" src="www.example.org"></iframe>

Safari on iPhone: Can I close the oauth browser tab?

I am using oauth to authenticate my iPhone-app's users. They click the login button and Safari opens to display the password entry page. Afterwards they are redirected using a custom url scheme, e.g. myapp://somethingsomething, which opens the application again (sending Safari into the background).
Can I close the browser tap during that redirect? Or directly afterwards via Javascript?
I ask because if my user imports a bording pass to his Passbook, Safari opens and logs my user in again, since the tab was still there.
Ok fixed by doing a setTimeout() call in JS before issuing the redirect. In the setTimeout() another redirect is executed: To a harmless page.

JQM 1.4 redirect user to page on app loaded

I've got a jquerymobile 1.4 application that has all the pages on the same html page (pages are broken into different divs).
What I'm looking for is an app-level initialiser event to subscribe to that allows me to do some logic checking (e.g. authentication status) and redirect them to a login page (say div#login) if necessary.
I've explored working with a popup, setting the login page to be dialog="true" and what I'm stuck with is how to redirect the user when the app first loads.
There's mobileinit and pagecontainercreate events. If I subscribe to the pagecontainercreate event then I can run a changePage function and that works, but then it transitions to the default page straight afterwards anyway.
As far as the ideal lifecycle:
mobile app finished loading -> show login dialog page -> init login page
What's happening now is:
pagecontainercreate -> show login dialog page -> close login dialog page and show home page automatically.

Facebook canvas app dialog redirect

Wanna execute user-to-user request dialog initiated by server side.
On my FB canvas application I have button "invite my friends". After user presses it, the POST request goes to my server and i redirect to FB request dialog using the following C# MVC code:
return Redirect("http://www.facebook.com/dialog/apprequests?app_id=MY_APP_ID&message=MESSAGE&redirect_uri=MY_APP_CANVAS_URL");
What i'm getting on Facebook canvas instead of "select users" dialog is the blank page with the FB logo href-ed to target page. How do i this confirmation to disappear?
Facebook typically doesn't allow for the content of a canvas page to be one of their dialog URLs. The way most developers work around this is to issue a client-side redirect to an absolute URL that redirects the entire page, instead of just the canvas iframe content.
For your purposes, you can achieve this by serving a minimal page as the response to the POST request that contains the following markup:
<script>
top.location="<%= (insert apprequest dialog URL here) %>";
</script>

Facebook Application and URLs

I developed a Facebook application using Ruby on Rails but I have a slightly annoying problem.
When I click any URL inside the application the application redirects to the correct view and everything is working just fine but the URL on the browser is not updating accordingly. The problem is that if I click refresh on the page I will be redirected to the home page of the directory ( that's correct because the URL in the browser is the home URL ) instead of the page that I was.
Example:
App URL:
https://apps.facebook.com/example
Clicking the books link is showing the page correctly but not modifying the browser's URL to:
https://apps.facebook.com/example/books
So next time that I will hit refresh I will be redirected to the home page because the browser link is still:
https://apps.facebook.com/example
Any suggestions?
you need to be aware that your app is an iframe app(i assume you didnt use FBML), that means it is contained in a iframe. So when you create your links, add a target=_top will change the url.
When You create a link You must define target with _parent like:
link

Resources