frequent
frequent

Reputation: 28503

How to avoid blank pages when using window.location.href with Jquery Mobile and RequireJS?

I'm using requireJS & Jquery Mobile.

I some areas off my app I'm doing a full page refresh (such as login/logout user). However, sometimes my plain vanilla

 window.location.href = 'index.cfm'

which I'm using to refresh doesn't work on iPad (running iOS3).

It's hard to pin down and debug, because I'm getting no error message in Mobile Safari and on desktop this never happens. Also, it usually happens the first time I fire up the application, so I thought it would be session related (running Coldfusion8/MySQL backend). But since everything works on desktop (even IE8...) it can't be some back end issue, can it?

The only thing I notice is that if the page load works, the title changes, then the spinner shows indicating page content is being loaded. If it doesn't work, the title changes and the spinner never shows, so I'm assuming the page content is not being loaded. This only seems to happen when I log in/out, which are the only two instances, where I'm using window.location.href

Question:
Any ideas how to debug this? What could be reasons this doesn't work? I have disabled pushstate and am wondering if a mere index.cfm vs a full path is the issue, but I'm having trouble to reproduce, so maybe someone can give me hint in another direction?

Thanks!

Upvotes: 1

Views: 1267

Answers (1)

xiaowl
xiaowl

Reputation: 5207

Any ideas how to debug this?

Yes, you can give weinre a try.

weinre is a debugger for web pages, like FireBug (for FireFox) and Web Inspector (for WebKit-based browsers), except it's designed to work remotely, and in particular, to allow you debug web pages on a mobile device such as a phone.

What could be reasons this doesn't work?

The reason is not that obvious to see. But I suggest you to use entire href instead of index.cfm. If you just want to reload, use location.reload([true/false]). Or you can change the pathname of location. Check the documentation of window.location for more details.

Upvotes: 1

Related Questions