Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to do refresh page with JAVA SCRIPT

Posted on 2007-04-09
6
931 Views
Last Modified: 2008-01-09
Hi Experts,

I have question about how to do refresh the pages with JAVA SCRIPT base on some issues as below:

- I have 3 banner images, each image link to orther URL when user click on the banner image.
- I have a banner html page that are display banner images by rotating with 10 sec

So, How to do this by using 1 HTML page and JAVA SCRIPT code?
Please help me if we can do this with JAVA SCRIPT.


The way I did is using META REFRESH tag, with this I need create 3 html pages and doing refresh with each pages as below:
on bn1.html

<meta http-equiv="refresh" content="10;url=http://192.168.1.1/htmlpages/bn2.html">
</head>
<body scroll="no" leftmargin="0" topmargin="0" BGCOLOR="#000000">
<table valign="top" height="30" width="288" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><a href="http://www.fix8.com/: target="_blank"><img       src="http://192.168.1.1/imgs/bn.jpg" border="0" height="65" width="395" align="center"></a></td>
  </tr>
</table>



Thank in advance!
0
Comment
Question by:CongUan
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Jaax
ID: 18874872
Using javascript:

Add onload
<body onload="callRefresh()" scroll="no" leftmargin="0" topmargin="0" BGCOLOR="#000000">

Within script tag add this function

<script>
  function callRefresh(){
      setInterval("URL", 10*1000); //Time is in milli seconds
  }
</script>
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 18877094
Here my example:

<html>
<head>
<title>Zvonko &#42;</title>
<base href="http://www.experts-exchange.com">
<style>
a.banner {display:none;}
</style>
<script>
var bNum = 0;
function showBanner(){
  var lnk = document.links;
  for(var b=i=0;i<lnk.length;i++){
    if(lnk[i].className=="banner"){
      lnk[i].style.display=(b==bNum)?"inline":"none";
      b++;
    }
  }
  bNum++;
  if(b==bNum) bNum = 0;
  setTimeout(showBanner, 3000);
}
</script>
<body scroll="no" leftmargin="0" topmargin="0" BGCOLOR="#000000" onLoad="showBanner()">
<table valign="top" height="30" width="288" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
<a class="banner" href="http://gmail.com/" target="_blank"><img src="/images/ta/medium/5374.png" border="0" height="65" width="395" align="center"></a>
<a class="banner" href="http://google.com/" target="_blank"><img src="/images/ta/medium/5375.png" border="0" height="65" width="395" align="center"></a>
<a class="banner" href="http://yahoo.com/" target="_blank"><img src="/images/ta/medium/5377.png" border="0" height="65" width="395" align="center"></a>
    </td>
  </tr>
</table>
</body>
</html>


0
 

Author Comment

by:CongUan
ID: 18880375
Thank Zvonko, it worked great.

Tx
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 18880513
You are welcome.

Do you know how to accept an Answer?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grunt script for Build Process 1 42
Button and js nou working 3 19
Google Analytics setup 5 50
How to make a good PHP + MySQL + JS pagination system? 3 31
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question