GWTで要素の色を検索しようとしていますが、何も取得していません(空の文字列)が返されました。私の問題は何ですか?位置は(問題がロギングとはないことを示す)「絶対」として示されている一方、空の文字列としてGWTで要素の色を取得
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.RootLayoutPanel;
public class Test implements EntryPoint {
Anchor a = new Anchor("Anchor");
@Override
public void onModuleLoad() {
RootLayoutPanel.get().add(a);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
log(a.getElement().getStyle().getColor());
log(a.getElement().getStyle().getVisibility());
log(a.getElement().getStyle().getPosition());
}
});
}
static native void log(String message) /*-{
console.log(message);
}-*/;
}
コンソールディスプレイの色および可視性:次のコードは、問題を示しています。結果はChromeとFirefoxで同じです。
「getComputedStyle」を試してください。たぶん、このポストはあなたを助けるでしょう:http://stackoverflow.com/questions/21797258/getcomputedstyle-like-javascript-function-for-ie8 – Adam