Skip to content

Commit eaa8275

Browse files
author
zhangxinxu
committed
FF in iframe
fix a bug that FF in iframe won't excute
1 parent e8797c0 commit eaa8275

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobilebone",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"description": "Bone main for mobile web APP with a sigle page mode.",
55
"main": "src/mobilebone.js",
66
"directories": {

src/mobilebone.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
var isSimple = /^.[^:#\[\.,]*$/
2828

2929
// Is it suppory history API
30-
var supportHistory = "pushState" in history &&
31-
"replaceState" in history &&
32-
// When running inside a FF iframe, calling replaceState causes an error
33-
!( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) &&
34-
( window.navigator.userAgent.search(/CriOS/) === -1 );
30+
var supportHistory = "pushState" in history && "replaceState" in history;
3531

3632
Mobilebone.support = supportHistory;
3733

@@ -44,7 +40,7 @@
4440
*
4541
* @type string
4642
**/
47-
Mobilebone.VERSION = '1.1.6';
43+
Mobilebone.VERSION = '1.1.7';
4844

4945
/**
5046
* Whether catch attribute of href from element with tag 'a'
@@ -100,13 +96,21 @@
10096
**/
10197
Mobilebone.pushStateEnabled = true;
10298

99+
if (// When running inside a FF iframe, calling replaceState causes an error. So set 'pushStateEnabled = false'
100+
!( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) &&
101+
( window.navigator.userAgent.search(/CriOS/) === -1 )
102+
) {
103+
Mobilebone.pushStateEnabled = false;
104+
}
105+
106+
103107
/**
104108
* Function for transition
105109
* In most cases, you are unnecessary to use this function , unlike Mobilebone.createPage
106110
107111
* @params pageInto: dom-object. Element which will transform into. - Necessary
108-
pageOut: dom-object. Elementwhich will transform out. - Optional
109-
back: boolean. Direction of tranisition. - Optional
112+
pageOut: dom-object. Element which will transform out. - Optional
113+
back: boolean. Direction of transition. - Optional
110114
options: object. Cover or add parameters. - Optional
111115
* @returns undefined
112116
* @example Mobilebone.transition(element);
@@ -297,7 +301,7 @@
297301
298302
* @params trigger: dom-object. element with tag-"a". - Optional(at least one)
299303
url: string. ajax url. - Optional(at least one)
300-
params: string|opject. ajax params. - Optional
304+
params: string|object. ajax params. - Optional
301305
* @returns string
302306
* @example Mobilebone.getCleanUrl(elementOfA);
303307
Mobilebone.getCleanUrl(elementOfA, '', "a=1&b=2");
@@ -366,8 +370,8 @@
366370
Mobilebone.createPage('<div class="page out">xxx</div>');
367371
Mobilebone.createPage('<p>xxx</p>');
368372
Mobilebone.createPage(pageDom, triggerLink);
369-
Mobilebone.createPage(pageDom, { reponse: '<div...>' });
370-
Mobilebone.createPage(pageDom, triggerLink, { reponse: '<div...>' });
373+
Mobilebone.createPage(pageDom, { response: '<div...>' });
374+
Mobilebone.createPage(pageDom, triggerLink, { response: '<div...>' });
371375
*
372376
**/
373377
Mobilebone.createPage = function(dom_or_html, element_or_options, options) {
@@ -435,7 +439,7 @@
435439
* @params keys: string. - Necessary
436440
* @returns function
437441
undefined keys is not string
438-
window keys unfinded
442+
window keys undefined
439443
* @example Mobilebone.getFunction("a.b.c");
440444
*
441445
**/
@@ -817,7 +821,7 @@
817821
return element;
818822
};
819823
/**
820-
* privite method: convert query string to key-value object
824+
* privatemethod: convert query string to key-value object
821825
**/
822826
var _queryToObject = function(string) {
823827
var obj = {};

0 commit comments

Comments
 (0)