why this code is not create a file in html5 - html

i want to create a 'abc.txt' file in the folder where the .html file exist. in html5.
i tri with this code:
<html>
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
function onInitFs(fs) {
fs.root.getFile('abc.txt', {create: true, exclusive: true}, function(fileEntry) {
}, errorHandler);
}
window.requestFileSystem(window.TEMPORARY, 1024*1024, onInitFs, errorHandler);
</script>
<input type="button" name="" id="" value="click" onclick="onInitFs(fs);"/>
</body>
</html>
But faild. Please tell me the correct method. (i tri with google chrome and letest firefox.)

From the documentation:
The LocalFileSystem interface of the File System API gives you access to a sandboxed file system.
It doesn't give you access to the main filesystem for the computer. It is a virtual one created by the browser. You can only access files in it that you put there from your own code.

Related

How to make my css import to html correct?

I am sorry, I am quite new in IT and I tried almost everything, I am frustrated that I am impossible to import correctly my .css file to my .html file. I looked on many other stackoverflow questions, for example: (1), (2), (3) and found no help. If I import my .css to html with <style></style> - it works, but with include file as "link href stylesheet" - it does not. I use Chrome browser Version 69.0.3497.100 (Official Build) (64-bit).
I tried to make html page with my openstreet map and that map has its own stylesheet included too. It not works because I can't include multiple css files to one html? I have .html file and .css file in the same folder. Why this: <link href='/styles.css' rel='stylesheet' /> is not working please?
My code(client.html):
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>The mapbox tutorial</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.49.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.49.0/mapbox-gl.css' rel='stylesheet' />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<link href='/styles.css' rel='stylesheet' />
</head>
<body>
<div>
<h1>MY new page</h1>
<div id="data">
Write me something: <input type="text" id="inputData">
<button id="myButRun">Send</button>
</div>
</div>
<div style="margin-left:10px; height: 500px; margin-top: 20px; width: 400px; " id='map'></div>
<script>
mapboxgl.accessToken = 'myPrivateKey';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v10',
center: [42.10, 57.14],
zoom: 11
});
map.on('load', function () {
map.addLayer({
"id": "data-update",
"type": "line",
"source": {
"type": "geojson",
"data": "empty"
},
"layout": {
"line-join": "round",
"line-cap": "round"
},
"paint": {
"line-color": "#faff00",
"line-width": 8
}
});
});
</script>
</body>
</html>
My code(styles.css):
body { margin:0; padding:0; }
#map{
border-style: solid;
border-width: 5px;
}
The / when using /styles.css indicates that the file is located in the web-root of the website. The web-root is the actual main directory served by the web-server for a configured website. When there's no web-server running, there's no actual web-root, from which the file can be read and deliverd to the browser.
In this case, where no web-server exists, the file was accessed directly from the local file system and using <link href='styles.css' rel='stylesheet'> will correctly reference the CSS file, which is located in the same directory as the HTML file.

Launch an application using HTML

I know that
<a href = 'ymsgr:sendim?contactID'>Send me a message</a>
will launch Yahoo Messenger.
can I create something like this to launch MSWord or my own application?
Here is an explanation of what you're describing: https://stackoverflow.com/a/16586294/4500419
And here you can find the URI specifications for Microsoft Office:
https://msdn.microsoft.com/en-us/library/office/dn906146.aspx#sectionSection4
So, something like
ms-word:ofv|u|http://yoursite.com/document.docx
Would open document.docx in read-only mode in MS Word.
And here's the doc on how to register your own application to a URI scheme in Windows:
https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx
This works also by simply naming the html file .hta which is fine if its for a local project
<html>
<head>
<title>Application Executer</title>
<HTA:APPLICATION ID="oMyApp" APPLICATIONNAME="Application Executer" BORDER="no" CAPTION="no" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" SCROLL="no" WINDOWSTATE="normal">
<script type="text/javascript" language="javascript">
function RunFile() { WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run("c:/windows/system32/notepad.exe", 1, false); }
</script>
</head>
<body>
<input type="button" value="Run Notepad" onclick="RunFile();"/>
</body>
</html>

i18next load json error(404 Not Found)

this is my code at index.html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
<script src="javascript/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="javascript/i18next-1.7.4.js" type="text/javascript"></script>
<title>i18next test</title>
</head>
<body>
<p id="id001" data-i18n="first_data">first</p>
</body>
<script type="text/javascript">
$(document).ready(function(){
language_complete = navigator.language.split("-");
language = (language_complete[0]);
i18n.init({
lng: language,
resGetPath: 'locales/__lng__.json',
fallbackLng: "en",
}, function(){
$("first_data").i18n();
});
});
</script>
</html>
And I've created 2 json file at the same directory with index.html
locales/en.json
locales/de.json
json file content:
{
"first_data": "de-first-data"
}
Firefox try to load de.json and en.json but get the error 404.
Do you have any idea why i18next cannot load the json file.
This is my folder structure below:
index.html
locales/de.json
locales/en.json
javascript/i18next-1.7.4.js
javascript/jquery-1.11.1.min.js
You host application in IIS. IIS by default (as far as I know) doesn't support JSON file type.
Following question is related to same problem:
ERROR 404.3 Not Found for JSON file
Have you tried with ?
resGetPath: 'javascript/locales/__lng__.json',

Google drive save to not working (Google drive api)

I am trying to make a website that will save a cat into the account of the user and have tried this:
<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-savetodrive"
data-src="http://example.com/pug-snores.mp3"
data-filename="pug-snores.mp3"
data-sitename="A Snoring Pug">
</div>
The save icon shows up but it does not save to the drive.
Why?
Thanks
try the explicit render: code from the google javascript api
<!DOCTYPE html>
<html>
<head>
<title>Save to Drive Demo: Explicit Render</title>
<link rel="canonical" href="http://www.example.com">
<script src="https://apis.google.com/js/platform.js">
{parsetags: 'explicit'}
</script>
</head>
<body>
Render the Save to Drive button
<div id="savetodrive-div"></div>
<script>
function renderSaveToDrive() {
gapi.savetodrive.render('savetodrive-div', {
src: '//example.com/path/to/myfile.pdf',
filename: 'My Statement.pdf',
sitename: 'My Company Name'
});
}
document.getElementById('render-link').addEventListener('click', renderSaveToDrive);
</script>
</body>
</html>
The data-src URL can be served from another domain but the responses from the HTTP server needs to support HTTP OPTION requests and include the following special HTTP headers:
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Range
Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range
If you want upload a local file with input file form and/or without php lib would be ...
<!DOCTYPE html>
<html>
<head>
<title>Save to Drive Demo: Explicit Render</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<form id="GDrive" name="GDrive" enctype="multipart/form-data" method = "post">
<input type="file" id="file" name="file" onChange="renderSaveToDrive('savetodrive-div', this.files[0].name,'GDrive');"><div id="savetodrive-div"></div>
</form>
<script>
function renderSaveToDrive(namediv, namefile, idfrm) {
window.___gcfg = {
lang: 'es-ES',
parsetags: 'explicit'
};
var xhr = new XMLHttpRequest();
var fd = new FormData(document.forms.namedItem(idfrm));
fd.append("file_new_name", namefile);
xhr.open("POST", location.href);
xhr.send(fd);
gapi.savetodrive.render(namediv, {
src: namefile,
filename: namefile,
sitename: 'GDrive Demo: Explicit Render'
});
}
</script>
</body>
</html>

SWFObject relative path

Whatever I try I couldn't make this swf file work.
if I put all the files into my root everything works perfectly fine.
Here is my path format;
root: where my index.php located.
inside the root, I have a folder called "public".
inside "public" I have another folder called "_carousel_flash".
This is the place where my swf file is located.
I also have "js" folder located in this directory.
Here is the html code I'm using for adding the swf file.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Galleria - Inspire Creativity</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="public/_carousel_flash/js/swfobject.js"> </script>
<script type="text/javascript" src="public/_carousel_flash /js/swfaddress.uncompressed.js"></script>
</head>
<body>
<div id="contents">
</div>
<script type="text/javascript">
var so = new SWFObject("public/_carousel_flash/block_slider.swf", "movie", "100%", "100%", "8", "#ffffff");
so.addParam("quality", "high");
so.addParam("id", "movie");
so.addParam("allowFullscreen", "true");
so.write("contents");
so.addParam("salign", "t");
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Galleria - Inspire Creativity</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="public/_carousel_flash/js/swfobject.js"> </script>
<script type="text/javascript" src="public/_carousel_flash /js/swfaddress.uncompressed.js"></script>
</head>
<body>
<div id="contents">
</div>
<script type="text/javascript">
var so = new SWFObject("public/_carousel_flash/block_slider.swf", "movie", "100%", "100%", "8", "#ffffff");
so.addParam("quality", "high");
so.addParam("id", "movie");
so.addParam("allowFullscreen", "true");
so.write("contents");
so.addParam("salign", "t");
</script>
</body>
</html>
PUBLIC spell mistake
Or else i guess <script> tag is causing some issues, try embedding your swf object file
I can't be sure what's causing your error, but here are some things I notice about your code:
You're using SWFObject 1.x, which is very outdated and uses different syntax than SWFObject 2.x. Do you have the correct swfobject.js file for SWFObject 1.x? This is a fairly common issue for SWFObject users.
In SWFObject 1.x, you can't addParam after the so.write statement... it will not be reflected in your page.
so.write("contents");
so.addParam("salign", "t");
should be
so.addParam("salign", "t");
so.write("contents");
You have a typo in the URL for SWFAddress (a space just before "/js/").
If you want to be sure your SWF is located in the root, try loading it directly in the browser using the absolute URL.
Speaking of absolute URLs, it's often helpful to try them in your SWFObject code, too. Your current URL is file-relative; I suggest either using a site-relative URL ("/foldername/filename.swf") or an absolute URL ("http://yourdomain.com/foldername/filename.swf").