When creating the page scripts within UI builder, servicenow doesn't allow you to use Web API (except console and timeout), hence you are not able to access document or window objects. One neat trick ...
Some results have been hidden because they may be inaccessible to you
Show inaccessible results