Skip to main content

Posts

Showing posts from December, 2018

.. things I learnt this year

Random things I learn't this year. 1. Flamingos arn't born pink They are born white and turn pink after eating lots of shrimp. 2. When lightning hits sand it creates glass sculptures. 3. In 1957 the BBC did April fools joke convincing the world that spaghetti trees were real 4. The Sydney opera house opened 10 years later than scheduled. 5. The biggest ferris wheel is 550 feet tall and is in  Las Vegas 6. Dark patterns are a thing and we should know about them. 7. A swede is made from a turnip and a cabbage. 8. Computer mice were first made of wood. 9. There is a bird called elephant bird and it was huge. 10. There are major reasons why humans sleep with some form of a blanket and its because we cannot regulate body temperature well during rem sleep. Article about it.  11. The difference between a mountain and a hill is only how hard it is to climb. No natural difference. 12. Oxford uni has a glass floor sports hall that changes lin

Changing chrome title tab when users leave

The other day I was on  https://fabriceleven.com/ reading one of their blogs and when I tabbed away I saw the title change and I thought it was cool as I had not seen anyone else use it before even though its pretty simple. So I went about doing it myself. I've done it in pure JS as a lot of the examples are jQuery and for simple things like this you don't need a library. You can see this working on this page just click on another tab then come back. Below is the code I used to achieve this. Simply put I get the html title tag. Add an event for when the user is away or using the page with blur and focus on the window. Then I pick a random string to display when they are away. <!DOCTYPE html> <html> <head> <title>Hi this is the original title</title> </head> <body> <p> lorem ipsm </p> </body> <script type="text/javascript"> var title = document.querySelector("title"); wind