473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Javascipt - Array- Iframe -Refresh

Can someone direct me, or give me advice...

I simply would like to load a random html page from an array into an
iframe upon refresh or visit. Every time the user visits the site a
diferent news article (html page) will present itself in the iFrame.

Feb 9 '06 #1
2 1977
Seven wrote:
I simply would like to load a random html page from an array into an
iframe upon refresh or visit. Every time the user visits the site a
diferent news article (html page) will present itself in the iFrame.


Including random content is a FAQ here. Please do a minimum of research
on previous articles before you post. <URL:http://jibbering.com/faq/>

FWIW: Include something like the following in the `body' element of your
HTML document.

<script type="text/javascript">
var
a = ["b", "c", "d"],
rnd = Math.floor(Math.random() * a.length),
url = a[rnd];

document.write([
'<iframe src="' + url + '" ...>',
' <a href="' + url + '">Go to article #' + rnd + '<\/a>',
'<\/iframe>'
].join("\n"));
</script>

Note that if you really want to use this client-side scripting instead of
the server-side scripting recommended here, users without client-side
script support will not see anything.
HTH

PointedEars
Feb 10 '06 #2
Exactly what I was looking for. Thank you!!

Feb 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Conax | last post by:
Hi, It's me again asking about IFRAME. With UncleWobby, Steven Burn and Roland Hall's help, I was able to create a proper IFRAME section on my page. Now I come to the next problem. I'd...
3
by: Troy | last post by:
Hello- I have a website that uses a custom built webserver to serve the pages. (Please don't ask me why my boss had his own web server written). I am displaying a log of information that is an...
3
by: Nigel Wroe | last post by:
I am using a shoutbox cgi and the messages are written to a file called tagbox.html using a form. After so many messages the file is blanked and new lines are written. I can cause a refesh say...
26
by: shlomi.schwartz | last post by:
using this example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test Page</title> </head>
0
by: Abhishek Srivastava | last post by:
Hello Everyone, I have two files. File 1 is called HTMLPage.html. The content of this file is <html><head><meta http-equiv='refresh' content='1'...
2
by: haieshwar | last post by:
Hi, I have a html page. This page has an iframe. When I press the refresh button or F5, is it possible for me to refresh only the iframe. Currently, when I press the refresh button, the whole...
11
by: mediagulch | last post by:
Hello, We are currently running banner ads on a few of our sites and we implemented a javascript so they refresh after every 20 seconds. The script works great in IE though in Firefox it doesn't...
1
by: helraizer1 | last post by:
Hi folks, and folkesses. I have a piece of java script for a dynamic menu (code below). <ilayer width=100% height=50 name="dep1" bgColor="#000000"> <layer name="dep2" width=100% height=50>...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.