javascript - Looping through all of the items in the window object -


last night, got bored , thought of little idea little script. thinking how many built-in functions php has compared javascript , realized don't know how many functions javascript has. thought of writing script through window object including every object inside object , forth. wrote script , worked (tried on smaller object).

however, problem javascript wont let me loop though whole windows object.

i have tried:

for (var key in window) {     console.log(key); } 

i tried:

var = object.create(window); (var key in a) {     console.log(key); } 

both snippets of code give me:

top window location external chrome intl v8intl document script1374438467163 $pick $try iframe elements overtext iframeshim mask clientcide dbug value debugcookie stylewriter stickywin tabswapper collapsible collapsable drag cookie accordion asset spinner multipleopenaccordion mootools typeof instanceof type hash native $a $arguments $chk $clear $defined $each $empty $extend $h $merge $lambda $mixin $random $splat $time $type $unlink browser $constructor window $family document $exec slick element uniquenumber $ getdocument getwindow selectors $$ addlistener removelistener retrieve store eliminate class chain events options request domevent event addevent removeevent addevents removeevents fireevent cloneevents fx swiff getsize getscroll getscrollsize getposition getcoordinates getheight getwidth getscrolltop getscrollleft getscrollheight getscrollwidth gettop getleft setcnetassetbasehref table behaviorapi behavior color $rgb $hsb $hex keyboard locale uri codemirror jshint _ emmet sidebar keymods layout mooshellactions base64 dropdown editorsmodified track update_resource_input remove_resource preparetosubmit submit_external_resource change_default_input_value validate warn disallowedplatforms default_code_mirror_options mooshelleditor mooshellsettings disqus_developer disqus_identifier disqus_title csspath jspath imgpath mediapath codemirrorpath panel_html panel_css panel_js makefavouritepath example_server username static_hash csrftoken mooshell preload_resources dp resources default_text add_external_resource_url _gaq towtruckconfig_enableanalytics towtruckconfig_cloneclicks towtruck _gat gaglobal style_html css_beautify js_beautify beautifier language heyoffline page_test key webkitnotifications localstorage sessionstorage applicationcache indexeddb webkitindexeddb webkitstorageinfo css performance console devicepixelratio stylemedia parent opener frames self defaultstatus defaultstatus status name length closed pageyoffset pagexoffset scrolly scrollx screentop screenleft screeny screenx innerwidth innerheight outerwidth outerheight offscreenbuffering frameelement crypto clientinformation navigator toolbar statusbar scrollbars personalbar menubar locationbar history screen postmessage close blur focus ondeviceorientation ontransitionend onwebkittransitionend onwebkitanimationstart onwebkitanimationiteration onwebkitanimationend onsearch onreset onwaiting onvolumechange onunload ontimeupdate onsuspend onsubmit onstorage onstalled onselect onseeking onseeked onscroll onresize onratechange onprogress onpopstate onplaying onplay onpause onpageshow onpagehide ononline onoffline onmousewheel onmouseup onmouseover onmouseout onmousemove onmousedown onmessage onloadstart onloadedmetadata onloadeddata onload onkeyup onkeypress onkeydown oninvalid oninput onhashchange onfocus onerror onended onemptied ondurationchange ondrop ondragstart ondragover ondragleave ondragenter ondragend ondrag ondblclick oncontextmenu onclick onchange oncanplaythrough oncanplay onblur onbeforeunload onabort getselection print stop open showmodaldialog alert confirm prompt find scrollby scrollto scroll moveby moveto resizeby resizeto matchmedia settimeout cleartimeout setinterval clearinterval requestanimationframe cancelanimationframe webkitrequestanimationframe webkitcancelanimationframe webkitcancelrequestanimationframe atob btoa addeventlistener removeeventlistener captureevents releaseevents getcomputedstyle getmatchedcssrules webkitconvertpointfrompagetonode webkitconvertpointfromnodetopage dispatchevent webkitrequestfilesystem webkitresolvelocalfilesystemurl opendatabase temporary persistent 

however, know there plenty more properties inside of windows object. such of svg functions , html functions. why javascript skipping many of properties in object?

in modern browsers object.getownpropertynames() , object.getprototypeof() properties of objects in prototype chain.

http://jsfiddle.net/ftvxn/

var obj = window;  object.getownpropertynames(obj).foreach(function(name) {        console.log(name);    }); while(obj = object.getprototypeof(obj)); 

if want see separation of prototype objects, add line provides divider.

http://jsfiddle.net/ftvxn/1/

var obj = window;  {     object.getownpropertynames(obj).foreach(function(name) {         console.log(name);     });     console.log("============================="); } while(obj = object.getprototypeof(obj)); 

i think recall in firefox, globals don't appear until access them. may need little experimenting if find case.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -