[removed] not working for me?

前端 未结 8 1967
栀梦
栀梦 2021-02-07 14:17

Well I\'m simply playing around with a userscript of GreaseMonkey and here\'s just something simple I attempt to do;

function test() {
document.getElementById(\'         


        
8条回答
  •  一个人的身影
    2021-02-07 14:43

    When you write document.onload = test(), you are calling the test function, and assigning its return value to the onload handler. This is clearly not what you intended.

    document.onload = test;
    

    This will assign a reference to the test function to the onload handler. When the event fires, that is when your function will be called.

提交回复
热议问题