Including javascript to google sites

后端 未结 2 723
孤城傲影
孤城傲影 2021-01-01 00:09

I\'m trying to include a simple javascript to Google Sites but I get nothing when pressing the button. I put the code inside an HTML Box. The code works perfectly when teste

2条回答
  •  误落风尘
    2021-01-01 01:10

    Google Sites will filter out operations it considers unsafe. Some details here, but was unable to find official documentation with quick search.

    As another answer mentions, your variables need var declarations. This is required because without this, the variables will become global to the window, and potentially could be used to escape whatever sandbox Google is putting around the sites javascript support, potentially causing security concerns.

    So to fix:

    var x = parseFloat(document.getElementById("value1").value);
    var y = parseFloat(document.getElementById("value2").value);
    

提交回复
热议问题