Connecting Tech Pros Worldwide Help | Site Map

Javascipt - Array- Iframe -Refresh

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 9th, 2006, 04:55 PM
Seven
Guest
 
Posts: n/a
Default 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.


  #2  
Old February 10th, 2006, 01:56 AM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default 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, 02:15 AM
Seven
Guest
 
Posts: n/a
Default Re: Javascipt - Array- Iframe -Refresh

Exactly what I was looking for. Thank you!!

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.