Fixed #1183: cc.game.setFrameRate doesn't work

I fixed cc.game.setFrameRate doesn't work on web.

cocos2d/cocos2d-js#1183

I'm sorry for new pull request, because i made some mistakes.

Anyway I tried to write reusable code about restart loops with a frame rate.

If it needs to update, please give me a advice.

It's my pleasure :)
I think it should be placed after cancelAnimationFrame, am I correct ?