官术网_书友最值得收藏!

jQuery Mobile and URLs

If you've opened test2.html in your browser and played with it, you may have noticed something interesting about the URLs as you navigate. The following is the initial http://localhost/mobile/c2/test2.html URL (the address and folder will, of course, differ on your computer).

After clicking on Products, the URL will change to http://localhost/mobile/c2/products.html. If I click on back and click on learn more, I will get http://localhost/mobile/c2/test2.html#aboutPage.

In both the subpages (the Products page and the About page), the URL was changed by the framework itself. The framework uses history.pushState and history.replaceState in the browsers that support it. For older browsers, or browsers that don't support JavaScript manipulation of the URL, hash-based navigation is used instead. The http://localhost/mobile/c2/test2.html#/mobile/c2/products.html URL is an example of how this link would look.

What's interesting is that, in this bookmark style, test2.html is always loaded first. You could actually build your products.html file to only include p and be assured that if the request was made for products first, it would still render correctly. It's the newer and fancier browsers that have an issue. If you didn't include the proper jQuery and jQuery Mobile includes, when they go directly to products.html, you would end up with a page that has no styles. It's best to simply always include your proper header files (the CSS, the JavaScript, and so on). Any decent editor will provide simple ways to create templates.

主站蜘蛛池模板: 阳泉市| 沾化县| 镇江市| 斗六市| 攀枝花市| 义乌市| 延寿县| 航空| 枣阳市| 泰来县| 施秉县| 南昌市| 岫岩| 镇江市| 名山县| 新河县| 金堂县| 射阳县| 东方市| 岑溪市| 巴塘县| 新和县| 孟连| 宝山区| 东阿县| 沾化县| 儋州市| 余庆县| 措美县| 山丹县| 镇宁| 紫阳县| 嘉义市| 高碑店市| 丁青县| 平果县| 云阳县| 江城| 新竹市| 吉隆县| 萨迦县|