JavaScript�Ńo�C�i�������� &
�@XPCOM���g���ă��[�J���̃f�[�^�x�[�X�ɃA�N�Z�X with Firefox
�̋L����ǂ�ł��āA�������� Ajax �ł͂ǂ��Ȃ�H�Ǝv���Ă���Ă݂��B
�� ���ɎQ�l�ɂ����͈̂ȉ��̋L���B
[comp]JavaScript�Ńo�C�i���t�@�C���̒��g�ɃA�N�Z�X�ł���
�� base64 �G���R�[�h�ɂ͉��L�̃R�[�h���g���܂����B
JavaScript �� Base64 �̕������ƕ�����
�T���v��
�T���v���̉摜�͌��X���������Ⴂ�̂Ŋg�債�Ă܂��B�i�g���܂킵�Ă�̂Łj
�\�[�X�R�[�h
<html><head>
<script type="text/javascript" src="base64.js"></script>
<script type="text/javascript">
load_url = function(url) {
var req = new XMLHttpRequest();
req.open('GET',url,false);
// XHR binary charset opt by Marcus Granado 2006
// [http://mgran.blogspot.com]
req.overrideMimeType('text/plain; charset=x-user-defined');
req.send(null);
if (req.status != 200) return '';
return req.responseText;
}
write_binary_file = function(url) {
// 49 => "1" (decimal)
var filestream = load_url(url);
var bytes = [];
for (i = 0; i < filestream.length; i++)
bytes[i] = filestream.charCodeAt(i) & 0xff;
// ����
var ele = document.createElement('img');
ele.src = 'data:image/gif;base64,' +
base64.encode(String.fromCharCode.apply(String, bytes));
document.getElementById('testBinery').appendChild(ele);
}
</script></head>
<body>
<input type="button" value="�ǂݍ���" onclick="write_binary_file('�摜�t�q�k')">
<div id=testBinery style="margin:15px"></div>
</body></html>
<script type="text/javascript" src="base64.js"></script>
<script type="text/javascript">
load_url = function(url) {
var req = new XMLHttpRequest();
req.open('GET',url,false);
// XHR binary charset opt by Marcus Granado 2006
// [http://mgran.blogspot.com]
req.overrideMimeType('text/plain; charset=x-user-defined');
req.send(null);
if (req.status != 200) return '';
return req.responseText;
}
write_binary_file = function(url) {
// 49 => "1" (decimal)
var filestream = load_url(url);
var bytes = [];
for (i = 0; i < filestream.length; i++)
bytes[i] = filestream.charCodeAt(i) & 0xff;
// ����
var ele = document.createElement('img');
ele.src = 'data:image/gif;base64,' +
base64.encode(String.fromCharCode.apply(String, bytes));
document.getElementById('testBinery').appendChild(ele);
}
</script></head>
<body>
<input type="button" value="�ǂݍ���" onclick="write_binary_file('�摜�t�q�k')">
<div id=testBinery style="margin:15px"></div>
</body></html>
���ǂ̂Ƃ���
[comp]JavaScript�Ńo�C�i���t�@�C���̒��g�ɃA�N�Z�X�ł���
�ŎQ�l�ɂ����Ă�������X�N���v�g�����傱���Ƃ������������ł��B
���ۂ̂Ƃ���A�o�C�i���[�f�[�^�ł����Ă� responseText �Ŏ擾�ł����ł����A�����A���̂܂g���Ɖ����Ă��܂���ł��ˁB
�n�߂́A�u��������������Ǝ��s���낵�Ă܂������A���߂����������̋L���������܂��āE�E�E�B���Ƀ��b�L�[�ł����B
��ŁA�ǂ�����ĉ������Ă��邩�Ƃ����� overrideMimeType �ł��B�����ŋ����I�Ɏw�肵�Ă��Ηǂ������킯�ł��B�ȁ[�B�ł��B
���Ȃ݂ɂ�������g���� cgi �ł� base64 �̕ϊ����킩��B
[JavaScript] data�X�L�[��URI�����i�摜�f�[�^��Base64�ϊ��j
�����A�����ȃc�[���������ď�����܂��B
�擾�����f�[�^�ɑ��Đ�� javascript �ł� base64 �G���R�[�h�Ɣ�r����Ɩʔ����ł��BoverrideMimeType ���Y��Ɉ�v���܂��B
���̋L���ւ̃R�����g