Ir para conteúdo

POWERED BY:

Arquivado

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

agnaldo35

[Resolvido] atualiza a pagina tem uma foto diferente

Recommended Posts

Ola pessoal estou com uma duvida, tem um website que toda vez que se atualiza a pagina tem uma foto diferente confira aqui >>>Clique aqui preciso fazer um site pra um camara e ele pediu isso, alguem pode me dar uma luz?

Compartilhar este post


Link para o post
Compartilhar em outros sites

como já citado, com javascript você pode fazer assim:

 

<div id="imagem"></div>

 

javascript

var listaImagens = new Array();
listaImagens[0] = 'imagem1.jpg';
listaImagens[1] = 'imagem2.jpg';
listaImagens[2] = 'imagem3.jpg';
// etc

window.onload = function(){
    var div = document.getElementById('imagem');
    var rnd = math.floor(math.random() * listaImagens.length);
    div.innerHTML = '<img src="' + rnd + '" alt="imagem" title="titulo da imagem">';
}

Mesmo assim movi para PHP por ser uma linguagem fácil, com mais gente dando suporte ondem podem te ajudar também.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você pode fazer assim em php:

 

$imagens = array(1 => "images/img1.jpg", "images/img2.jpg", "images/img3.jpg", "images/img4.jpg");
$img_rand = array_rand($imagens, 1);

echo '<img src="'.$imagens[$img_rand].'" border="0" />';

Criei com array pois fica mais simples pra você do que com banco de dados.

Compartilhar este post


Link para o post
Compartilhar em outros sites

pessoal agradeceria se pudessem me dizer como ficaria esse codigo na pagina , aqui esta o codigo

as imagens que quero se chamam ( images/slide1.jpg, images/slide2.jpg, images/slide3.jpg) obrigado a todos!!

 

 

 

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="en-us" http-equiv="Content-Language" />
<meta name="author" content="webtunes" />
<meta name="description" content="description of this website" />
<meta name="keywords" content="keywords" />
<title>Julio Estados Unidos</title>
<!-- style sheets -->
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/main-menu.css" />
<link rel="stylesheet" type="text/css" href="prettyPhoto/css/prettyPhoto.css" />
<link rel="stylesheet" type="text/css" href="css/nivo-slider.css" />
<!-- jQuery framework and utilities -->
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="prettyPhoto/js/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="js/init-prettyPhoto.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="js/jquery.nivo.slider.pack.js"></script>
<!-- testimonial slide-->
<script type="text/javascript" src="js/testimonial_slideshow.js"></script>
<!-- cufon text -->
<script type="text/javascript" src="js/Aller_400-Aller_700.font.js"></script>
<script type="text/javascript"> 
      Cufon.replace('h1,h2,h3,h4',{fontFamily:'Aller',fontWeight :'700'});
</script>
<!-- nivo slider  -->
<script type="text/javascript"> 
$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:20,
		animSpeed:1000,
		pauseTime:6000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next/Prev
		directionNavHide:true, //Only show on hover
		keyboardNav:true, //Use left / right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8 //Universal caption opacity
	});
});
</script>
</head>
<body>
<div id="wrap">
  <div id="header">
    <div id="header_top"></div>
    <h1 class="logo"><a title="#" href="index-2.html">amedeo</a></h1>
    <div id="search">
      <form  action="http://themeforest.oroian.ro/amedeo/blue/index.html">
        <fieldset>
        <input name="search" type="text"  onblur="if (this.value==''){this.value='Search our website...'};" onfocus="if(this.value=='Search our website...'){this.value=''};" value="Search our website..."/>
        <input name="search" type="submit" value="" class="button"/>
        </fieldset>
      </form>
    </div>
    <div class="clear"></div>
    <ul id="nav">
      <li class="top"><a href="index-2.html" class="top_link"><span>Home</span></a></li>
      <li class="top"><a href="javascript: void(0)" class="top_link"><span class="down">Profile</span></a>
        <ul class="sub">
          <li><a href="index-2.html" >Profile</a></li>
          <li><a href="index-content-slider.html" >Profile</a></li>
          <li><a href="index-news-slider.html" >Profile</a></li>
          <li><a href="index-no-slider.html" >Profile</a></li>
          <li><a href="blog.html">Profile</a></li>
          <li><a href="blog_post.html">Profile</a></li>
          <li><a href="full-page.html" >Profile</a></li>
          <li><a href="two-columns.html" >Profile</a></li>
          <li><a href="three-columns.html" >Profile</a></li>
          <li><a href="javascript: void(0)" class="fly"><span>Second Level</span></a>
            <ul>
              <li><a href="#">Subitem 1</a></li>
              <li><a href="#">Subitem 2</a></li>
              <li><a href="#">Subitem 3</a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li class="top"><a href="javascript: void(0)" class="top_link"><span>Practice</span></a>
        <ul class="sub">
          <li><a href="index.html">Practice</a></li>
          <li><a href="../black/index.html">Practice</a></li>
          <li><a href="../brown/index.html">Practice</a></li>
          <li><a href="../green/index.html">Practice</a></li>
          <li><a href="../purple/index.html">Practice</a></li>
        </ul>
      </li>
      <li class="top"><a href="index.html" class="top_link"><span>About Us</span></a></li>
      <li class="top"><a href="services.html" class="top_link"><span>Services</span></a></li>
      <li class="top"><a href="projects.html" class="top_link"><span>Projects</span></a></li>
      <li class="top"><a href="blog.html" class="top_link"><span>Blog</span></a></li>
      <li class="top"><a href="typography.html" class="top_link"><span>Typography</span></a></li>
      <li class="top"><a href="contact.html" class="top_link"><span>Contact Us</span></a></li>
    </ul>
    <!-- end main menu -->
  </div>
  <!-- end header -->
  <div id="inside_wrap">
    <div class="breadcrumb">
    </div>
    <div id="left_large_page" class="clearfix">
      <div class="main_content">
        <h1>Company Information</h1>
    <div id="slider"> <img  src="content_images/slide1.jpg" alt="slide1" /> <img  src="content_images/slide2.jpg" alt="slide2" /> 
		<img  src="content_images/slide3.jpg" alt="slide3" /> </div>
     <p></p>
      </div>
      <!-- end main content -->
      <div class="right_column">
        <div class="item">
          <h3>Testimonials</h3>
          <div id="testimonial_slideshow">
            <div class="testiomonial_item">
              <p><i>texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto te</i></p>
              <p><b>Agnaldo Santos</b></p>
            </div>
            <div class="testiomonial_item">
              <p><i>texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto te</i></p>
              <p><b>Agnaldo Santos</b></p>
            </div>
            <div class="testiomonial_item">
              <p><i>texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto texto te</i></p>
              <p><b>Agnaldo Santos</b></p>
            </div>
          </div>
          <p class="text_right"><a href="#"><img src="img/testimonial-back-btn.png" alt="back" width="25" height="20" id="slidePrev" /></a><a href="#"><img src="img/testimonial-next-btn.png" alt="next" width="25" height="20" id="slideNext" /></a></p>
        </div>
        <div class="divider"></div>
        <div class="item">
          <h3>Quick Links</h3>
          <ul class="sec_nav">
            <li><a href="index-2.html"><span>Home</span></a></li>
            <li><a href="index-content-slider.html">Profile</a></li>
            <li><a href="index-news-slider.html">Offices</a></li>
            <li><a href="index-no-slider.html">Practice areas</a></li>
            <li><a href="blog.html">About us / history</a></li>
            <li><a href="blog_post.html">Contact</a></li>
            <li><a href="full-page.html">Our Services</a></li>
            <li><a href="two-columns.html">Who We Are</a></li>
            <li><a href="three-columns.html">Diversity</a></li>
          </ul>
        </div>
        <div class="divider"></div>
        <div class="item">
          <h3>Info Point</h3>
          <p class="info_point">Global Financial and Credit Crisis Resources.</p>
          Headquartered in New York, we have lawyers operating out of 11 offices in the US, Europe, Asia and Latin America.
          <p class="text_right"><a href="index.html" class="button"><span>Learn More</span></a></p>
        </div>
        <div class="divider"></div>
        <div class="item">
          <h3>Get in touch with us</h3>
          Do you have any questions? Call us now at
          <div class="phone">
            <h2>0008 000 000</h2>
          </div>
          Or you can use our online form
          <p><a href="contact.html" class="button"><span>Contact Us Now</span></a></p>
        </div>
        <div class="divider"></div>
      </div>
      <!-- end right column -->
    </div>
    <!-- end page content -->
    <div class="footer ">
      <div class="content">
        <ul class="footer_nav clearfix">
          <li class="one-fourth">
            <h4>Our Services</h4>
            <ul class="pages">
              <li><a href="index-2.html">Home</a></li>
              <li><a href="#">Who We Are</a></li>
              <li><a href="#">Our Services</a></li>
              <li><a href="index.html">About Us</a></li>
              <li><a href="services.html">Services </a></li>
              <li><a href="projects.html">Projects</a></li>
              <li><a href="blog.html">Blog</a></li>
              <li><a href="contact.html">Contact Us</a></li>
            </ul>
          </li>
          <li class="one-fourth">
            <h4>CATEGORIES</h4>
            <ul class="pages">
              <li><a href="#">Updates</a></li>
              <li><a href="#">News</a></li>
              <li><a href="#">Press Releases</a></li>
              <li><a href="#">New Offers</a></li>
              <li><a href="#">Our Staff </a></li>
              <li><a href="#">Policy</a></li>
              <li><a href="#">Events</a></li>
            </ul>
          </li>
          <li class="one-fourth">
            <h4>STAY CONNECTED</h4>
            <span>Get the latest updates on your 
            favorite social networks.</span>
            <div class="social_icon"> <a href="#"><img src="content_images/facebook.gif" width="16" height="16" alt="Facebook" /></a> <a href="#"><img src="content_images/in.gif" width="16" height="16" alt="Linkedin" /></a> <a href="#"><img src="content_images/twitter.gif" width="16" height="16" alt="Twitter" /></a> <a href="#"><img src="content_images/picasa.gif" width="16" height="16" alt="Picasa" /></a> <a href="#"><img src="content_images/yahoo.gif" width="16" height="16" alt="Yahoo" /></a> <a href="#"><img src="content_images/google.gif" width="16" height="16" alt="Google" /></a> <a href="#" class="last"><img src="content_images/youtube.gif" width="16" height="16" alt="Youtube" /></a> <a href="#"><img src="content_images/flickr.gif" width="16" height="16" alt="Flickr" /></a> <a href="#"><img src="content_images/myspace.gif" width="16" height="16" alt="MySpace" /></a> <a href="#"><img src="content_images/blogger.gif" width="16" height="16" alt="blogger" /></a> <a href="#"><img src="content_images/delicious.gif" width="16" height="16" alt="delicious" /></a> </div>
          </li>
          <li class="one-fourth last">
            <h4>CONTACT INFORMATION</h4>
            <ul>
              <li><b>E-mail:</b> <a href="mailto:info@mywebsite.com">info@mywebsite.com</a></li>
              <li><b>Telephone:</b> 0080 000 000</li>
              <li><b>Fax:</b> 0080 000 000</li>
              <li><b>Address:</b><br/>
                1600 Amphitheatre Parkway
                Mountain View, CA 94043 </li>
            </ul>
          </li>
        </ul>
      </div>
      <div class="copy clearfix">
        <div class="left">©2010 Julio Company. All rights reserved.</div>
        <div class="right"><a href="full-page.html">Privacy Policy</a> | <a href="full-page.html">Terms and Conditions</a> | <a href="full-page.html">
			Website By Agnaldo Santos</a></div>
      </div>
    </div>
    <!-- end footer -->
  </div>
  <!-- end inside wrap -->
  <div id="inside_wrap_bottom"></div>
</div>
<!-- end wrap -->
</body>
 
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

isso ficaria assim?

 

 <div id="imagem">
   <script type="text/javascript">
   

 var listaImagens = new Array()
;listaImagens[0] ='content_images/slide1.jpg'
;listaImagens[1] ='content_images/slide2.jpg';
listaImagens[2] ='content_images/slide3.jpg'; 
window.onload = function(){  
var div = document.getElementById('imagem');   
var rnd = math.floor(math.random() * listaImagens.length);   
div.innerHTML = '<img src="' + rnd + '" alt="imagem" title="titulo da imagem"/>';}</script>
    
    </div>

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.