xul:를 열고 html 파일을 상대적인"프로그램이 setup.xul"에 xul 브라우저

StackOverflow https://stackoverflow.com/questions/104267

  •  01-07-2019
  •  | 
  •  

문제

에서 짧은: 어떤 방법을 찾기 위해 현재 디렉토리의 전체 경로를 xul 응용 프로그램?

긴 설명:

하고 싶어 html 파일에서 xul 브라우저 응용 프로그램입니다.의 경로를 html 파일을 설정해야에서 프로그래밍 방식으로 xul 응용 프로그램.Html 파일이 있는 외부의 폴더 내 xul 응용 프로그램이지만,동일한 수준입니다.(사용자는 모두 체크아웃 폴더에서 SVN,없이 설치할 수 있 xul 응용 프로그램)

그것을 열어 파일을 정밀하면 나는 설정의 전체 경로를 좋아요"file:///c: emp\processing-sample\index.html"

내가 무엇을 하고 싶은 파일을 열려면 상대와 나 xul 응용 프로그램.

나는 열 수 있는 사용자의 프로파일 경로:

var DIR_SERVICE = new Components.Constructor("@mozilla.org/file/directory_service;1", "nsIProperties");
var path = (new DIR_SERVICE()).get("UChrm", Components.interfaces.nsIFile).path;
var appletPath;

// find directory separator type
if (path.search(/\\/) != -1)
{
appletPath = path + "\\myApp\\content\\applet.html"
}
else
{
appletPath = path + "/myApp/content/applet.html"
}

// Cargar el applet en el iframe
var appletFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
appletFile.initWithPath(appletPath);
var appletURL = Components.classes["@mozilla.org/network/protocol;1?name=file"].createInstance(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(appletFile);
var appletFrame = document.getElementById("appletFrame");
appletFrame.setAttribute("src", appletURL); 

어떤 방법을 찾기 위해 현재 디렉토리의 전체 경로를 xul 응용 프로그램?

도움이 되었습니까?

해결책

나는 해결 방법을 발견: http://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO 할 수 없을 정확히 열고 파일을 사용하여 상대적인 경로를"../../index.html"그러나 나는 응용 프로그램을 얻을 수 있습 directory 및 작동합니다.

var DIR_SERVICE = new Components.Constructor("@mozilla.org/file/directory_service;1", "nsIProperties");
var path = (new DIR_SERVICE()).get(resource:app, Components.interfaces.nsIFile).path;
var appletPath;

다른 팁

Yes,html 파일 안에 확장할 수 있습 해결 chrome 을 사용하여 Uri.예를 들어에서 하나의 확장자:

content.document.location.href = "chrome://{appname}/content/logManager/index.html"

에 xul 응용 프로그램에 액세스할 수 있습니다 chrome 폴더에의 응용 프로그램을 사용하여 크롬 url.

나는 비교적 작은 경험을 가진 요소,그래서 나는 확실하지 않는 경우에 이를 정확하게 작동할 것입니다.그것은 방법은 당신이 포함 javascript 원본 파일에서 당신의 xul file:

<script src="chrome://includes/content/XSLTemplate.js" type="application/x-javascript"/>

그래서,아마도 이 파일에 있는 c:\applicationFolder\chrome\content\index.html 액세스할 수 있습니다:

chrome://content/index.html 

에서 몇 가지 패션입니다.

당신은 또한 볼 수 있습니다 와 관련된, 리를 단순화하는 많은 것을 포함한 파일 i/o.IIRC,나는 데 문제가 상대적인 경로를 사용하여'../',하지만.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top