Connecting Tech Pros Worldwide Help | Site Map

Javascipt - Array- Iframe -Refresh

  #1  
Old February 9th, 2006, 05:55 PM
Seven
Guest
 
Posts: n/a
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.

  #2  
Old February 10th, 2006, 02:56 AM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a

re: Javascipt - Array- Iframe -Refresh


Seven wrote:
[color=blue]
> 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.[/color]

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
  #3  
Old February 11th, 2006, 03:15 AM
Seven
Guest
 
Posts: n/a

re: Javascipt - Array- Iframe -Refresh


Exactly what I was looking for. Thank you!!

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get Javascipt output to file? joe answers 1 April 2nd, 2008 07:05 PM
Where is the "javascipt console" in 9.00? cool2005 answers 1 July 27th, 2006 08:25 AM
AOL 9 and javascipt Karen Baron answers 12 July 23rd, 2005 02:57 PM
Applet - Javascipt communication. Roberto Gallo answers 1 July 20th, 2005 02:37 PM
javascipt .js inclueds in a php html echo Chris Dean answers 1 July 16th, 2005 11:57 PM