'document' is not defined
zhangxuanru opened this issue · comments
zxr commented
otto := Otto.New()
otto.Set("require", require)
otto.Run(require("js/echarts.js"); require("js/1.js");
)
1.js:
console.log(document)
func require(call Otto.FunctionCall) Otto.Value {
file := call.Argument(0).String()
fmt.Printf("requiring: %s\n", file)
data, err := ioutil.ReadFile(file)
if err != nil {
fmt.Println(err)
panic(err)
}
_, err = call.Otto.Run(string(data))
//fmt.Println(string(data))
if err != nil {
fmt.Println(err)
panic(err)
}
return Otto.TrueValue()
}
'document' is not defined。 How to deal with this mistake?
Asday commented
document
is not part of ES5. That's an implementation-specific thing.