Foros del Web » Programando para Internet » Javascript »

Desplegar cartel si no esta cierta url en el history

Estas en el tema de Desplegar cartel si no esta cierta url en el history en el foro de Javascript en Foros del Web. Tengo un sitio, el cual nesecito que si al cargarlo, el usuario no paso por otra url antes le salga un cartel tipo "TIENE QUE ...
  #1 (permalink)  
Antiguo 21/03/2008, 11:18
 
Fecha de Ingreso: diciembre-2004
Mensajes: 139
Antigüedad: 19 años, 4 meses
Puntos: 1
Desplegar cartel si no esta cierta url en el history

Tengo un sitio, el cual nesecito que si al cargarlo, el usuario no paso por otra url antes le salga un cartel tipo "TIENE QUE PASAR POR WWW.PAGINA.COM ANTES"

Se puede ?
  #2 (permalink)  
Antiguo 21/03/2008, 23:33
Avatar de Bellenger  
Fecha de Ingreso: noviembre-2004
Ubicación: En un lugar del Mundo...
Mensajes: 599
Antigüedad: 19 años, 5 meses
Puntos: 4
Re: Desplegar cartel si no esta cierta url en el history

Caramba hice unas pruebas y lo unico que consegui es que me salga un error:
Código:
Error: uncaught exception: Permiso denegado para obtener la propiedad History.current
jeje por lo visto en firefox no se puede accerder a la lista de urls, visitadas, seguire intentando algo haber que se me ocurre, pero por lo visto no se puede jejeje...
__________________
Un Caballero Jura Lealtad. Usa su espada para suprimir la Injusticia No Conoce el Odio y Tampoco el AMOR...
  #3 (permalink)  
Antiguo 23/03/2008, 04:47
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Re: Desplegar cartel si no esta cierta url en el history

Combinando css con lenguaje de servidor es posible detectar si una url ha sido visitada (no es necesario javascript en realidad, pero en el ejemplo lo usé por comodidad). El truco consiste en colocar un archivo php (o de cualquier lenguaje de servidor), que entregue un content-type:image como background en la pseudoclase visited de un enlace (digo en enlaces por Explorer, en el resto de los navegadores podrían ser otros tipos de elementos):
Código PHP:
<?php
session_start
();
if(isset(
$_GET['im'])){
header("Content-type:image/jpeg");
$im='/9j/4AAQSkZJRgABAQEACgAKAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCAAKAAoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDt6KKKAP/Z';
echo 
base64_decode($im);
if(isset(
$_SESSION['en_historial']))
        if(
in_array($_GET['im'],$_SESSION['en_historial']))
            exit;
$_SESSION['en_historial'][]=$_GET['im'];
exit;
}
if(isset(
$_GET['ver_en_historial'])){
$html='';
if(
count($_SESSION['en_historial'])==0){
echo 
'document.getElementById("lista").innerHTML="Ninguno figura en el historial"';
exit;
}
foreach(
$_SESSION['en_historial'] as $v)
    
$html.=$v.'<br />';
echo 
'document.getElementById("lista").innerHTML="'.$html.'"';
exit;
}
?>
<!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>test</title>
<style>
a:link,a:active,a:hover{ 
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:9px;
color:#FF0000;
background:url(no_visitada.jpg);
}
</style>
<script>
function rpc(url){
    oldsc=document.getElementById("old_sc");
       if(oldsc)
            document.getElementsByTagName('body')[0].removeChild(oldsc);
    sc=document.createElement('script');
    sc.id="old_sc";
    sc.src=url+'&'+Math.random();
    document.getElementsByTagName('body')[0].appendChild(sc);

function addCss(cssCode,i) {
    control=document.getElementById(i)
    if(control)
        document.getElementsByTagName("head")[0].removeChild(control)
    var styleElement = document.createElement("style");
    styleElement.type = "text/css";
    if (styleElement.styleSheet) {
        styleElement.styleSheet.cssText = cssCode;
    } else {
        styleElement.appendChild(document.createTextNode(cssCode))
    }
    styleElement.id =i;
    document.getElementsByTagName("head")[0].appendChild(styleElement);
}
window.onload=function(){
    enlaces=document.getElementsByTagName('a');
    for(i=0;i<enlaces.length;i++){
        cssCode='a#'+enlaces[i].id+':visited{font-family:Verdana, Arial, Helvetica, sans-serif;font-size:9px;color:#FF0000;background:url(<?php echo basename($_SERVER['PHP_SELF']) ?>?im='+enlaces[i].href+');}';
        addCss(cssCode,'tt'+i)
    }
}
</script>
</head>

<body>
<p><a id="uno" href="http://www.google.es">Google</a><br />
  <a id="dos" href="http://www.yahoo.com">Yahoo</a><br />
  <a id="tres" href="http://www.php-hispano.net">php-hispano</a><br />
  <a id="cuatro" href="http://www.neocreativo.es">neocreativo</a></p>
  <a href="javascript:rpc('?ver_en_historial')">ver cuáles figuran en tu historial</a>
  <div id="lista"></div>
</body>
</html>
Podés ver un ejemplo en este enlace: http://www.disegnocentell.com.ar/new..._historial.php

Última edición por Panino5001; 23/03/2008 a las 04:54
  #4 (permalink)  
Antiguo 23/03/2008, 10:32
Avatar de Bellenger  
Fecha de Ingreso: noviembre-2004
Ubicación: En un lugar del Mundo...
Mensajes: 599
Antigüedad: 19 años, 5 meses
Puntos: 4
Re: Desplegar cartel si no esta cierta url en el history

Interesante la solucion con php, jeje no me lo imaginaba de esa manera, Saludos...
__________________
Un Caballero Jura Lealtad. Usa su espada para suprimir la Injusticia No Conoce el Odio y Tampoco el AMOR...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:45.