add page visibility event

for issue#233 

simulation  "Page Visibility Event" in js.
I think this's a easy way to  impletment the Page Visibility feature.

By the way , I removed some trailing whitespaces.