Solved

How to do refresh page with JAVA SCRIPT

Posted on 2007-04-09
6
930 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trying to redirect after event in javascript 3 24
how i fix Remove render-blocking JavaScript 3 60
If condition on Html with Asp 11 18
jQuery Scroll To Top 5 11
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

831 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