Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Fleury

Ajax browser

Recommended Posts

Código de minha autoria =)

Só roda no seu domínio. Senão dá acesso negado.

<!--	Autor: Diego Fleury		Data: 03/02/2006		Site: http://forum.imasters.com.br/index.php?showforum=143--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Browser Simulator v0.1</title><style type="text/css"><!--#context {	position: relative;	width: 98%;	height: 78%;	z-index: 1;	border: 1px solid #666666;	overflow: auto;}--></style><script type="text/javascript"><!--function MM_reloadPage(init) {  //reloads the window if Nav4 resized  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);//===============================================================================================================================function xmlhttpInit () {	var req;	try {		req = new ActiveXObject("Microsoft.XMLHTTP");	} catch ( e ) {		try {			 req = new ActiveXObject("Msxml2.XMLHTTP");		} catch ( ex ) {			try {			 req = new XMLHttpRequest();			} catch ( exc ) {			 alert("Seu browser nao suporta XMLHTTP.");			 req = null;			}		}	}	return ( req );}function openUrl (url) {	var xmlhttp = xmlhttpInit();		if (url.indexOf('http://'+document.location.hostname) != 0) {		alert('Você só pode navegar pelas páginas a partir do domínio:\n  http://'+document.location.hostname);		return false;	}		if ( xmlhttp ) {		document.getElementById('carregando').style.display = 'block';				xmlhttp.open( "GET", url, true );		xmlhttp.onreadystatechange = function () {			if ( xmlhttp.readyState == 4 ) {				if (xmlhttp.status == 200) {									var context = unescape(xmlhttp.responseText.replace(/\+/g," "));					document.getElementById('context').innerHTML = context;					regHistory(url);				} else {				  alert('Não foi possível abrir o endereço!\nErro: '+xmlhttp.statusText);			  }								document.getElementById('carregando').style.display = 'none';			}		};		xmlhttp.send( null );	}	delete xmlhttp;}var hist = new Array();function regHistory (url) {	if (hist[hist.length-1] != url) hist.push(url);	if (hist.length > 1) document.getElementById('voltar').disabled = false;}function histBack () {	document.getElementById('url').value = hist[hist.length-2];	openUrl(hist[hist.length-2]);	hist.pop();	if (hist.length == 1)	document.getElementById('voltar').disabled = true;}function checkSubmit (event,url) {  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;  if(keyCode == 13) {		openUrl(url);		return false;	}}//--></script></head><body onload="document.getElementById('url').value = 'http://'+document.location.hostname+'/'"><form id="form1" name="form1" method="post" action="">  <label><input type="button" name="voltar" value="Voltar" accesskey="v" tabindex="1" disabled="true" onclick="histBack()" /></label>  <br />  <label>E<ins>n</ins>dereço:</label> <input type="text" name="url" id="url" accesskey="n" tabindex="3" size="40" onKeyPress="return checkSubmit(event,this.value);" />  <label><input type="button" name="ir" value="Ir" accesskey="i" tabindex="4" onclick="openUrl(document.getElementById('url').value);" /></label>	<label id="carregando" style="display:none">Carregando...</label></form><hr color="#333333" /><br /><div id="context"></div></body></html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

A idéia era fazer um browser interno com opção de avançar e voltar.Quanto a renderizar o css e javascript da página traga, ele deixa um pouco a deseja.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.