How does loading all pages with ajax affect the back button? - ruby-on-rails

I'm a newby working on my first site. I'm using a music player that I would like to have play continuously throughout the site, so I'm researching the consequences of loading the site's various account pages with AJAX (ala Soundcloud or Spotify). I'm curious to know how this will affect the back button.
If the site is completely AJAX, when the user hits the back button to go back to (apparently) a previous account page, the site will be lost to the previous site in the browser's history. However, if Soundcloud's pages are loaded via AJAX, they've modified the back button to accommodate switching to the previously loaded AJAX page.

well, after 5 seconds of google I found HTML5 history.pushState
EDIT. Ended up going with rack_pjak

Related

Using history.back() in UIWebView but loaded pre page contains very old data

IOS 8.0+
My app use UIWebview to visit a forum site.
The forum front page contains two tag: default one is 'Recommend', another one is 'Newest'. Using ajax to load post data When user switch to 'Newest' tag, at the same time the page runs the follow codes to save state:
window.history.pushState(null, title, url);
After that if user is interesting with some post, he/she would click link and jump to a new page to view detail of the post. In this page, I use follow code to let user have a way to go back to 'Newest':
history.back(-1);
Now interesting thing happened, go back to 'Newest' tag but post data is old.
After some tests, I found the data is always be the first time loaded after installed the app. This bug will not happen in Safari or Android app.
I believe it should have some relationship with webView cache.But why UIWebview does't use new cache? And how to
solve this problem?
Oh no...nobody meet this problem?
My current solution is:
use js code to auto refresh the page when go back.

Backbone and jQuery Mobile App resetting after browser back button

I am building an app using Backbone.js and jQuery Mobile. On some pages in my app I have external href links and I'm running into an issue.
When a user clicks and external href link, get taken to the external site and then hits the back button. My app does not load from the proper page where the user originally left the app from.
In fact my entire DOM is reset so it looks like my site gets a complete refresh and doesn't keep any of its former state.
I have been trying to search for a solution but this issue is kind of hard to word out. I hope it makes sense.
Does anyone have any suggestions?
UPDATE
Stupid error on my part.. I had a bad id set on the page and it didn't load the data I had saved in the session for it when a user returns to the page.. Changed the id and all is well. Thanks!
Link
Make you external links open up new tabs.
If you have used one html with multiple pages solution then there's an explanation for this.
rel="external" will cause a full page refresh so last page location will not be remebered. When you return to the last location it will trigger new refresh and the first page will be shown again.
This can be prevented with a multiple html page solution.

jquery slider with url changer [duplicate]

I am writing a complex AJAX application at the moment and the entire site has clean URLs. At the moment PHP creates the basic layout for each page however I don't want to have to navigate away from each page when the user clicks on a link, and I don't want to have a hash in the URL because it won't fit with the rest of the site. I know that this has cropped up loads before on the site and it seems to be quite commonly asked but I was wondering if there was a neat HTML5 way of just appearing to change the URL in the address bar even if it technically remains on the same page.
You can do it with history.pushState, but only in browsers that support it. Just try the following line in your browsers JavaScript-Console.
history.pushState({},"URL Rewrite Example","https://stackoverflow.com/example")
More on that in The pushState() method (Mozilla Developer)
Similar question How do I, with JavaScript, change the URL in the browser without loading the new page?
As others have stated, HTML5's history.pushstate is the way to go. Try browsing a repo on github to see it in action (https://github.com/visionmedia/express).
Trouble is the only version of IE that supports history.pushstate is IE10, which kinda sucks.
Plenty of sites use hashbang #! URL's such as Twitter (e.g. https://twitter.com/#!/Sironfoot ). The hashbang is a URL pattern agreed on by search engines so that they can still trawl and index a heavily Ajax powered website (more info here http://code.google.com/web/ajaxcrawling/docs/specification.html), so you could go that route.
The only other approach is to use history.pushstate for browsers that support it, and fall back to full-page refreshes for non-supporting browsers.

How to update iframe page tab content using a form?

I am trying to pass data using a form to a Facebook iFrame page tab but can't seem to figure how to do it.
I have a page tab on my Facebook page with several elements such as links and images directing users to various pages on the main website. This is updated every week, so rather than update the HTML file and upload via FTP everyweek i would like to see if i can create a form to pass the new data to the iframe.
In addition the Facebook page tab cannot be created in PHP as the server is running ASP.NET
I am trying to do this without the use of a database table if possible, using POST or GET would be preferable.
If anyone knows of any tutorials or has any tips i would be very grateful.
Cheers
You can only pass content or interact with iframe content if it's on the same domain as the parent webpage that has the iframe. All browsers have a "same origin policy" that prevent you from being able to do that - sorry :(

Hard refreshes and SEO

I couldn't find an answer to this on the web. I have a site, where I try to avoid hard refreshes as much as possible. It's a sequences of photos, and upon a user click of a central div, a little page (a RoR partial) loads within that div with a new photo in it.
The user keeps clicking, the photo keeps changing, and the URL of the page never changes. The title of the photo does change though. And so I want the web crawlers to see this...
Is there any advantage to having a hard refresh or not in this scenario? Will the Web Crawlers see the title of the photo in the div, and index my home page? Or at least the url of the inner div?
I hope this makes sense! Thanks!
It all depends on what you mean by a hard refresh. If all of the pictures, and their related data (title etc.) are loaded when the page first loads, and the click is just a javascript event that changes the css a bit to display the next picture then that has no negative effect on SEO. If clicking that link makes an ajax request back to your server to retrieve the image, then it will never get picked up by the search engine web crawler, and will not contribute to SEO.
If you aren't sure if this click is an ajax request, or just a css change, you can look at your html source to figure it out. If all your image tags are in your html source then it's not making an ajax request. If you only see one (or zero) then it is making an ajax request.
If the page title would never change, then there's no benefit. But if you're loading a new image, the page title should change for optimal SEO.
There's a workaround, though. Just make it to where you can access the images specifically with a static page and make sure Google spiders it. You can keep the normal page flow as-is using this method.
Edit: I should add that I had a site that got 60% of it's traffic from Google Image searches, so I'd say you'd definitely want them indexed separately.

Resources