Is this a bug of “location.hash”? (JavaScript, Cordova, WebApp)

When I use "location.hash=pageId" to jump to another page (in the same HTML file, jQuery: data-role="page"), after I change the innerHTML of a DIV (to change the text content of it) for the first time, the text content will not change as I wish, furthermore it'll disappear at all! And the element after it will move up. And the backgroundImage will not change as I wish also (it won’t disappear, it just remains unchanged).

Both weird quirks will disappear since the second change. After that, everything will be ok.

And another problem is, when I jump to another page using “location.hash=pageId”, there will be a whole blank screen to flash for a short while, not just a smooth and normal jump. I don’t want the short while blank flash to show up. Even more, I wish there could be some transitional animation effect for the jumping. Are there any solutions for this?

Thanks a lot in advance.

1
2 comments

I think, you'd better post this on StackOverflow - this forum is mainly intended to discuss WebStorm issues... Also, I don't think anybody can help you unless you provide the code...

Are you running in browser, or on device? the are some issues with location.hash on devices - https://openradar.appspot.com/22186109

1
Avatar
Permanently deleted user

Thank you so much, Elena! This is my second time getting your help.

I'm running on device, using Cordova to develop a hybrid app.

I've solved the second problem by replacing "location.hash='#pageId'" with the jQuery Mobile method: changePage(). But the first one still remains. So, it's none business of "location.hash".

(I use "prototype" in the codes, because every time when I use "this", WebStorm will hint me: don't use it, it's not safe.)

0

Please sign in to leave a comment.