이 문제에 관해서는 몇 가지 해결책이 있지만 내 상황과 관련이 없습니다.런타임에 GWT의 CSS 테마를 변경하는 방법은 무엇입니까?
내 war 폴더에 별도의 CSS 파일이 있습니다.
W3-테마 blue.css 내 전쟁 폴더에
내 전쟁 폴더에W3-테마 red.css.
지금은 파란색 테마를로드 할 경우, 나는
<link rel="stylesheet" href="/w3-theme-blue.css">
내가 빨간색 테마를로드 할 경우, 난 내 project.html 파일이 쓰기 내 project.html 파일이 쓰기
<link rel="stylesheet" href="/w3-theme-red.css">
이제는 실행 시간에 파란색에서 빨간색 또는 그 반대로 변경하는 것이 좋습니다.
나는이 Element s = DOM.createElement("link");
s.setAttribute("type", "text/css");
s.setAttribute("href", "w3-theme-red.css");
DOM.getElementById("body").appendChild(s);
처럼
http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
이 JSNI로 이것을 사용되는 자바 스크립트에서이 하나 있지만,
그때 내가 GWT에서 동일한 코드를 구현하려고 행운을 확인
하지만 여전히 운이 ...
Pl
// safe your StyleElement that is returned with injectStyleSheet()
// so you can override it later with a new style
public static StyleElement content;
[...]
CssResource style = GWT.create(CssBundle.class);
content = StyleInjector.injectStylesheet(style.css1().getText());
은 당신이 할 수있는 다른으로 나만의 스타일을 바꾸려면 : 당신이 JSNI
private native void loadCSS (String cssHref) /*-{
$doc.write('<link rel="stylesheet" type="text/css" href="' +
cssHref + '">');
}-*/
감사합니다,하지만 document.wrtie 함수, 응답을 편집 어떤 제안 – junaidp
... GWT에서 JSNI 구문을 확인하십시오 아니라고한다 –