Banner Rotativo (IMG) não funciona no Maldito Internet Explorer

jobranco

Membro
Bom Dia Pessoal,

Estou com um banner rotativo de imagens msm, mas só q ele nao funciona no IE !!!
No FireFox ele fuciona perfeito ...
Lembrete *Meu IE está todo atualizado na ultima versão*

Segue o codigo:

<script language="JavaScript">
var how_many_ads = 14;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="";
url="firewall.html";
alt="";
banner="rotativo/debian.gif";
width="";
height="";
}
if (ad==2) {
txt="";
url="antivirus.html";
alt="";
banner="rotativo/macaffe.gif";
width="";
height="";
}
if (ad==3) {
txt="";
url="servidoresdemensagens.html";
alt="";
banner="rotativo/officialpenguin_mini.gif";
width="";
height="";
}
if (ad==4) {
txt="";
url="aplicacoes.html";
alt="";
banner="rotativo/vmware.gif";
width="";
height="";
}
if (ad==5) {
txt="";
url="servidoresdeaplicacao.html";
alt="";
banner="rotativo/window-embedded.gif";
width="";
height="";
}
if (ad==6) {
txt="";
url="roteadores.html";
alt="";
banner="rotativo/3com.jpg";
width="";
height="";
}
if (ad==7) {
txt="";
url="telefoniaip.html";
alt="";
banner="rotativo/asterisk.jpg";
width="";
height="";
}
if (ad==8) {
txt="";
url="areasdeatividade.html";
alt="";
banner="rotativo/avaya.jpg";
width="";
height="";
}
if (ad==9) {
txt="";
url="acessoremoto.html";
alt="";
banner="rotativo/citrix1.jpg";
width="";
height="";
}
if (ad==10) {
txt="";
url="thinclient.html";
alt="";
banner="rotativo/connec.jpg";
width="";
height="";
}
if (ad==11) {
txt="";
url="thinclient.html";
alt="";
banner="rotativo/dnthin.jpg";
width="";
height="";
}
if (ad==12) {
txt="";
url="servidores.html";
alt="";
banner="rotativo/ibm.jpg";
width="";
height="";
}
if (ad==13) {
txt="";
url="areasdeatividade.html";
alt="";
banner="rotativo/intelbras.jpg";
width="";
height="";
}
if (ad==14) {
txt="";
url="cabeamentoestruturado.html";
alt="";
banner="rotativo/furukawa.jpg";
width="";
height="";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
</script>

Alguem sabe como posso fazer pra funcionar no IE ?

Agradeço desde já
Obrigado
o/
 
Banner Rotativo de imagens ... todas vez q eu der um F5 na pagina ele vai seleicionar umas dessas 14 imagens e mostra-la =]

mas no IE as imagens nem aparecem (espaço fica branco)
ja no firefox funciona perfeito
 
Bem, a base de dados apenas serve para estatísticas, mas podem criar uma para as imagens ao invés de as terem apenas no php. Eu vou dar o exemplo com 2 imagens.

Criação da tabela:
Código:
CREATE TABLE IF NOT EXISTS `nome_da_tabela` (
  `ip` varchar(50) collate latin1_general_ci NOT NULL,
  `views` int(11) NOT NULL,
  `clicks` int(11) NOT NULL,
  `cc` varchar(50) collate latin1_general_ci NOT NULL,
  `country` varchar(50) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
Ficheiro includes/db.inc.php
PHP:
<?php
        /*  Database Information - Required!!  */
        /* -- Configure the Variables Below --*/
        $dbhost = 'localhost';
        $dbusername = '';
        $dbpasswd = '';
        $database_name = '';
        /* Database Stuff, do not modify below this line */
        $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
                or die ("Couldn't connect to server.");
        $db = mysql_select_db("$database_name", $connection)
                or die(" $database_name - Couldn't select database.");
?>
Ficheiro imagem.php
PHP:
<?php
        ini_set('display_errors', '0');
        error_reporting (E_ALL); // Report everything
        include("includes/db.inc.php");
        session_start();
        // Add a view
        $ip = $_SERVER['REMOTE_ADDR'];
        $handle = fopen("http://www.ipdomain.info/cc[".$ip."]", "r");
        $cc = stream_get_contents($handle);
        fclose($handle);
        $handle = fopen("http://www.ipdomain.info/country[".$ip."]", "r");
        $country = stream_get_contents($handle);
        fclose($handle);
        if(!mysql_num_rows(mysql_query("SELECT `ip` FROM `nome_da_tabela` WHERE `ip`='$ip'"))) {
                mysql_query("INSERT INTO `nome_da_tabela` values('$ip', 1, 0, '$cc', '$country')");
        }
        else {
                mysql_query("UPDATE `nome_da_tabela` SET `views` = `views` + 1 WHERE `ip`='$ip'");
        }

        header('Content-type: image/gif');
        if(rand(1,2) == 1) {
                $stream = fopen('images/pub1.gif', 'r');
                $_SESSION['image'] = 1;
        }
        else {
                $stream = fopen('images/pub2.gif', 'r');
                $_SESSION['image'] = 2;
        }
        echo stream_get_contents($stream);
        fclose($stream);

?>
Ficheiro visit.php
PHP:
<?php

        ini_set('display_errors', '0');
        error_reporting (E_ALL); // Report everything
        include("includes/db.inc.php");
        session_start();
        // Add a view
        $ip = $_SERVER['REMOTE_ADDR'];
        $handle = fopen("http://www.ipdomain.info/cc[".$ip."]", "r");
        $cc = stream_get_contents($handle);
        fclose($handle);
        $handle = fopen("http://www.ipdomain.info/country[".$ip."]", "r");
        $country = stream_get_contents($handle);
        fclose($handle);
        if(!mysql_num_rows(mysql_query("SELECT `ip` FROM `nome_da_tabela` WHERE `ip`='$ip'"))) {
                mysql_query("INSERT INTO `nome_da_tabela` values('$ip', 1, 1, '$cc', '$country')");
        }
        else {
                mysql_query("UPDATE `nome_da_tabela` SET `clicks` = `clicks` + 1 WHERE `ip`='$ip'");
        }
        if(!isset($_SESSION['image'])) $link = "http://www.oteusite.com"; // Se não estiver definido
        if($_SESSION['image'] == 1) $link = "http://www.outrosite.com";
        if($_SESSION['image'] == 2) $link = "http://www.outrosite2.com";
        header("Location: $link");

?>
Ficheiro .htaccess
Código:
RewriteEngine on
RewriteRule ^pub.gif$ imagem.php [L]
RewriteRule ^page$ visit.php [L]
Agora é só darem o link de www.aminhapagina.com/publicidade/pub.gif e que seja redireccionado para www.aminhapagina.com/page

Através deste código, recriando a imagem.php
PHP:
<?php
        header('Content-type: image/gif');
        $max = 14;
        $rand = rand(1, $max);
        if($rand == 1) {
           $stream = fopen('images/image1.gif', 'r');
        }
        elseif($rand == 2) {
           $stream = fopen('images/image2.gif', 'r');
        }
// Aqui até se podia utilizar um case, era o melhor. mas podes fazer copy paste até chegar ao fim
        echo stream_get_contents($stream);
        fclose($stream);
?>
Isto seria num ficheiro à parte, aproveita o .htaccess e assim tens num ficheiro a imagem a rodar.
 
:lol:
aIUHAiuaUIHAuiAHUIHAiuAHIUahaIUHAiuhAIUHaiaIAuhaIUHAuiha
se eu nao especificar os pixelx das imagens (width e height) ae nao vai aparecer msm xD~

DERR marquei gostoso xD~

Mas vlw pela ajuda Anjo2

Obrigado hehe
 
através do php podes definir o tamanho das imagens, mas quando fazes <img src="images/image.gif" width="200" height="200" /> funciona em 200x200
 
Back
Topo