Solve browser support bug: toElement didn't exist in FF