0
我正在使用Node Webkit創建桌面應用程序以在磁盤上創建文件。它正在工作,但是當我嘗試將成功的消息發送到頁面時,它會重新加載將標題欄更改爲index.html的頁面並刪除之前的標題。我做錯了什麼?節點Webkit應用程序和頁面顯示
這是代碼:
<!DOCTYPE html>
<html lang='en'>
<head>
<title>GPS API Client Builder</title>
<script type="text/javascript">
var nw = require('nw.gui');
//Window Menu
var windowMenu = new nw.Menu({
type: 'menubar'
});
//Help Menu
var helpMenu = new nw.Menu();
// Add to window menu
windowMenu.append(new nw.MenuItem({
label: 'Help',
submenu: helpMenu
}));
//About sub entry
helpMenu.append(new nw.MenuItem({
label: 'About',
click: function() {
alert('I made this!');
}
}));
//Assign window
nw.Window.get().menu = windowMenu;
</script>
</head>
<body>
<h1>GUIApp!</h1>
<!--<script src='script.js' type="text/javascript "></script>-->
<script type="text/javascript ">
var os = require('os');
var os = require('os');
var fs = require('fs');
var content = "";
console.log('estoy en script file');
content += 'This is a test of writing string to a text file' + os.EOL;
content += 'This is a test of writing string to a text file' + os.EOL;
content += 'This is a test of writing string to a text file' + os.EOL;
content += 'This is a test of writing string to a text file' + os.EOL;
console.log('content: ' + content);
//write to file
fs.writeFile('output.txt', content, function(err) {
if (err) {
document.write('Error writing file');
//console.log('error writing');
} else {
document.write('file successfully created');
// console.log('file successfully created');
}
});
</script>
</body>
</html>