Solved

How to do refresh page with JAVA SCRIPT

Posted on 2007-04-09
6
928 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank Zvonko, it worked great.

Tx
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
You are welcome.

Do you know how to accept an Answer?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now