The toSource() function, which we talk about yesterday(Javascript – Print an object with alert()), only works in Firefox, a more proper way which work in non Gecko engine browser like Chrome and Safari is using console.
console.log(yourObject); console.info(yourObject); console.warn(yourObject); console.error(yourObject);
Try the following example.
<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script> <script type="text/javascript"> $(document).ready(function() { myWebsite = new Object(); myWebsite.name = 'Eureka!'; myWebsite.url = 'https://ykyuen.wordpress.com/'; console.log(myWebsite); console.info(myWebsite); console.warn(myWebsite); console.error(myWebsite); }); </script> </head> <body> <p>Eureka!</p> </body> <html>
Done =)