Jump to content


R P Laurindo's Content

There have been 2 items by R P Laurindo (Search limited from 25/04/2023)


Ordernar por                Order  

#1015275 Script Para Carregar Scripts

Posted by R P Laurindo on 01/12/2011, 20:38 in Javascript / DOM / AJAX / ECMAScript

//alert('loaded!');

var
	arrPath = new Array(),
	indexCount = 0;

set_load_path = function(path){
		
	var
		last = path.charAt(path.length -1);
		
	if (last != '/')
		path += '/';
	
	arrPath[indexCount] = path;
	indexCount++;
};

loadScript = function(file){
	var
		arrCount = arrPath.length,
		script = null; var states = '';
	
	for (var i=0; i < arrCount; i++){
	
		script = document.createElement('script');

		script.type = "text/javascript";
		script.charset = 'UTF-8';
		
		if(arrPath)
			script.src = arrPath + file;	
		else
			script.src = file;
		
		// DOM é case sensitive? 
		script.onLoad = script.onreadystatechange = function(){
			
			if (script.readyState == 'complete')
				document.head.appendChild(script);
			
			states += script.readyState + '\t';
		}
		
	}
	alert(states);
};

Como podem ver, a função set_load_path assim como a set_include_path no PHP, define os caminhos onde estarão todos os scripts usados em um dado processamento, dessa forma não precisamos ficar incluindo o mesmo path trocentas vezes. A função loadScript varre o array de paths e tenta carregar o script, mas tem algo que não está saindo bem. Teste e vamos fazer isso funcionar porque será muito útil.



#1014407 [Resolvido] Página Com Audio De Fundo

Posted by R P Laurindo on 28/10/2011, 12:49 in HTML, CSS e Metodologias

Pessoal, estou tentando colocar uma música de fundo no FF, mas não funciona fazendo assim

<embed src="file:///c:/arquivo.mp3" hidden="hidden"/>



O problema está em file:///, porque ao usar http:// funcionou perfeitamente.

Descobri o problema, no FF devemos acrescentar o type = "audio/mpeg". O problema é que não dá para usar
style = "display:none"
porque aí para de funcionar novamente, mas dá para usar
style = "visibility:hidden"


O problema é que ocupa lugar na página. Não sei como burlar isso. Eu se ique os desenvolvedores do FF se preocupam com a segurança, mas aí já é demais.

Resolvi com a tag audio inserida no HTML5.

<audio autoplay="autoplay" type="audio/ogg" src="file:///....ogg"></audio>


É isso aí galera. Até a próxima. Só não sei como postar como resolvido!




IPB Skin By Virteq