在Haxe中处理javascript文档

问题描述:

对于“hellow html5-haxe world”测试,我试图打印当前的URL。不幸的是,似乎没有办法使用Haxe js.html.Document类。编译器的目标是js和一个跟踪(“hello world”)(它在Chrome开发者控制台中可见)。在Haxe中处理javascript文档

根据这一类的文档,

Each web page loaded in the browser has its own document object. This object serves as an entry point to the web page's content (the DOM tree, including elements such as <body> and <table>) and provides functionality global to the document (such as obtaining the page's URL and creating new elements in the document).

要访问的URL没有在类“URL”字段。

我试图让这个类失败:

var url:String = js.html.Document.URL; //does not work, URL is not static. 

var tmp = new js.html.Document(); //does not work, this class has no constructor. 
var url:String = tmp.URL; 

在javascript中的“文件”是建立在全局命名空间,允许我们访问HTML页面。但是,Haxe似乎没有像对象那样的“文档”,也没有某个js类的getDocument()静态函数。

如何访问js.html.Document类?

var doc = js.Browser.window.document; 
var url = doc.URL; //or any other document command supported by the browser. 

(这个答案被埋葬在访问`js.html.Document`都在[API文档]中提到的https://groups.google.com/forum/#!topic/haxelang/y084mee_YDw

+1

更多方式http://api.haxe.org/js/html/ Document.html)。 – 2014-09-25 18:21:04