Slice method does not exist in Safari, substitute with webkitSlice.