Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialdanielperez
Full Stack JavaScript Techdegree Student 15,993 PointsDifference between window.alert() and alert().
I have MAC OS 10.10.5 and Safari 9.0.3 and latest Chrome browser. I found that alert() does nt work on my MAC in either browser. But window.alert() works.
On Windows 7 and 10 PC, no matter which browser, both window.alert() and alert() work.
In my testing the user see can see no difference, except for maybe the font of the pop-up notification.
For reference W3C schools Javascript tutorial, http://www.w3schools.com/js/js_output.asp.
3 Answers
Chyno Deluxe
16,936 PointsHello Daniel,
They are both the same. alert() is shorthand for window.alert(). I am not familiar with Mac so I wouldn't be able to help you troubleshoot why one works over the other but I wanted to state that they are one in the same.
danielperez
Full Stack JavaScript Techdegree Student 15,993 PointsYa, i know I guess my browser crashed
I deleted my browser cache and restarted my browser on each test
Not until I restarted my MAC did alert() start working as expected
Only posting this because many seem to have the same thing happen
danielperez
Full Stack JavaScript Techdegree Student 15,993 PointsThanks for confirming, though
Thought I was going nuts there for a second!
danielperez
Full Stack JavaScript Techdegree Student 15,993 Pointsdanielperez
Full Stack JavaScript Techdegree Student 15,993 PointsSo I know this alert() really should work on my MAC using Safari or Chrome Why doesn't it work!? (yes, I double and triple checked my syntax)
So on my MAC under Safari Preferences, Security, turned off "block pop-ups" and in Plug-In, listed under Java are ...the teamtreehouse.com ... the workspace (port-....teamtreahouse.com) chose always allow, or allow
Still on my MAC, alert() produces no expected notification windows hm....!?
Restarted my Safari browser tried again still alert() did not work
Restarted my Safari browser made sure to set to always open in tabs still alert() did not work hm....!?!?!?
I downloaded the workspace project files to my Mac and tried the same... still alert() did not work hm....!?!?!??!?!?!
So finally, I restarted my MAC Wala!! ...alert() produces the window notifications. Chrome or Safari... in a separate window or in a tab.... Now works as expected.