Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Kreative

  • Rank
  • Birthday 07/27/2000

Previous Fields

  • Languages
    Java, Python, JavaScript, HTML

Profile Information

  • Location
    London, United Kingdom
  • Interests
    Game Design
    Game Development
    Pixel Art
  1. Is it possible to generate a reference or obtain some function that I can hide, that gives innerWidth and innerHeight even if window.innerWidth and/or innerHeight have been replaced? Maybe this could be rephrased as: can the properties be made non-replaceable?
  2. Hello, I would like to define non-replaceable references/getters to the innerWidth and innerHeight properties of window, or whatever they reference and are updated by. This is because currently, I can very easily re-assign, delete or re-define these properties to any other value making them unreliable if they were accidentally tampered with. Research In Mozilla, Object.getOwnPropertyDescriptor(window, x) where x is innerWidth or innerHeight, returns a descriptor of a configurable and enumerable property with a getter and setter containing functions that I can retrieve, bind to window and isolate. However, in Chrome, the function returns a descriptor of a property that does not contain a getter or setter, but rather a value, that magically updates when the inner window is resized given that the property has never been manually re-assigned, re-defined or deleted. Reading Mozilla Developer Network, I have found the specification that describes these two properties is that of the CSS Object Model ( link: https://drafts.csswg.org/cssom-view/#dom-window-innerwidth ). In this specification I have located the `partial interface Window` which defines these view-port properties as `[Replaceable] readonly attribute long` where the [Replaceable] means that the property can be re-assigned and will continue to indefinitely reference the new re-assigned value whilst keeping the same property name, despite it being read-only. This explains the behavior I have seen in Chrome, however there seems to be no means to extract a function or generate a reference that I could potentially hide in a closure or a block and (not 100% but mostly) reliably use it as the true width and height of the inner-window in pixels. Seeing as I can expose and isolate a getter in Mozilla, is there any (perhaps other) way to utilise a slightly safer means of getting the innerWidth and innerHeight of window? Because in terms of JavaScript, the two properties seem to be magical in how they update as doing something like Object.defineProperty(window, 'innerWidth', Object.assign(Object.getOwnPropertyDescriptor(window, 'innerWidth'), {writable: false, configurable: false}) does the same thing as re-assigning and then freezing the property afterward; nothing. Kind Regards, Augustas.
  3. Learning javascript and creating my own object orientation.

  • Create New...