Javascript Safari - Syntaxerror: Unexpected Token '>'
Solution 1:
Arrow function ()=>{} is es6 feature, firefox and chrome both are already supported. But safari old version doesn't. Please check http://kangax.github.io/compat-table/es6/ for more information.
Solution 2:
Safari 5.1 is really bad !!!
Example it does not load with =>
var t=w.map(v =>String.fromCharCode(v));
Replacement it will take charge
var t=w.map(function(v){returnString.fromCharCode(v)});
To make a script work on all browsers, avoid,
- The
=>
and preferfunction () {}
instead - The
function (param = x) {}
, preferfunction (param) {if (param == 'undefined') {param = x;}}
- The
let
and usevar
instead.
Solution 3:
The problem is with the arrow function syntax from es6 as Jerry Zhu already mentioned.
To support older browsers you need to replace "response => {" with "function(response) {" and also "setTimeout(() => {" with "setTimeout(function() {".
Solution 4:
Advice for you to be quiet with all browsers ...
Avoid using the
VAR => RESULT VAR
, preferfunction (VAR) {return RESULT VAR;}
Never use parameters in your codes with values like:
function (VAR = DEFAULTVALUE) {}
Usefunction (VAR) {if (VAR == "undefined") VAR = DEFAULTVALUE;}
To get an object:
document.getelementByID
To specify an uninitialized property, choose
Object.setAttribute (property, value)
rather thanObject.property = value
. This can lead to errors or inappropriate behavior.
Some Styles properties can only be used if you set them up, especially the CSS3. Javascript accepts the same thing as CSS provided that you respect its usage.
- to get DOM coordinates browsers from Netscape X and IE or other browser Opéra, FireFox, Apple X, etc...
this.Ypos = document.body.scrollTop + ((! this.IE)? e.pageY: (window.event.y));
this.Xpos = document.body.scrollLeft + ((! this.IE)? e.pageX: (window.event.x));
If coordinates smartphones Event page.X is : Event.changedTouches[e.changedTouches.length-1].pageX
;
- To print an object in document:
Object.appendChild (mebox)
I'm 53 years old, I've been working on the Internet for 35 years and since then nothing has really changed.
Post a Comment for "Javascript Safari - Syntaxerror: Unexpected Token '>'"