473,385 Members | 1,569 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,385 software developers and data experts.

How can I dynamically set a frame's source?

Hi,

I've been looking through books and posts, but so far I can't find
anything that really addresses this problem. I have a frameset page
with three frames, one on top with static content, and two below
(vertical) where I want the content to change depending on the day of
the week. Although I've tried several things already, which haven't
worked, this is where it is now (for one of the child frames; the other
child frame (tomorrow) would mostly mirror this code):

</head>
<script type="text/javascript">
//<![CDATA[
// get current date from local computer and set as a variable
var dtNow == getDay();

//find today's day and set source page for child frame
function change_page(){
if (dtNow == 0) frame.today.location = "Sunday.html";

else if (dtNow == 1) frame.today.location = "Monday.html";

else if (dtNow == 2) frame.today.location = "Tuesday.html";

else if (dtNow == 3) frame.today.location = "Wednesday.html";

else if (dtNow == 4) frame.today.location = "Thursday.html";

else if (dtNow == 5) frame.today.location = "Friday.html";

else if (dtNow == 6) frame.today.location = "Saturday.html";
}
document.onLoad.change_page
//]]>
</script>
<body>

I have also tried "document.location =" and "parent.today.location ="
I'm sure it's something basic I'm forgetting here. I'd appreciate any
help!

Thanks,

Carol

Dec 6 '06 #1
5 1836
ASM
Be*******@gmail.com a écrit :
Hi,

I've been looking through books and posts, but so far I can't find
anything that really addresses this problem.
to address to a frame :

parent.name_Of_My_Frame

no need id
Although I've tried several things already, which haven't
worked, this is where it is now (for one of the child frames; the other
child frame (tomorrow) would mostly mirror this code):
you are a very nutty person, it is very naughty to use framed page !
</head>
<script type="text/javascript">
//<![CDATA[
var dtNow == getDay();

//find today's day and set source page for child frame
function change_page(){
// get current date from local computer and set as a variable
var dtNow = new Date();
dtNow = dtNow.getDay();
// find the page
var page = '';
switch(dtNow) {
case 0: page = 'Sunday'; break;
case 1: page = 'Monday'; break;
case 2: page = 'Tuesday'; break;
case 3: page = 'Wednesday'; break;
case 4: page = 'Thursday'; break;
case 5: page = 'Friday'; break;
default: page = 'Saturday'; break;
}
return page;
}

onload = function(){parent.today.location = change_page()+'.html';}

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 6 '06 #2

ASM wrote:
Be*******@gmail.com a écrit :
Hi,

I've been looking through books and posts, but so far I can't find
anything that really addresses this problem.

to address to a frame :

parent.name_Of_My_Frame

no need id
Although I've tried several things already, which haven't
worked, this is where it is now (for one of the child frames; the other
child frame (tomorrow) would mostly mirror this code):

you are a very nutty person, it is very naughty to use framed page !
</head>
<script type="text/javascript">
//<![CDATA[
var dtNow == getDay();

//find today's day and set source page for child frame

function change_page(){
// get current date from local computer and set as a variable
var dtNow = new Date();
dtNow = dtNow.getDay();
// find the page
var page = '';
switch(dtNow) {
case 0: page = 'Sunday'; break;
case 1: page = 'Monday'; break;
case 2: page = 'Tuesday'; break;
case 3: page = 'Wednesday'; break;
case 4: page = 'Thursday'; break;
case 5: page = 'Friday'; break;
default: page = 'Saturday'; break;
}
return page;
}

onload = function(){parent.today.location = change_page()+'.html';}

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Hi Stephane,

Thanks for the reply.
Hmmm. I haven't tried a switch. But I did try the onload=function and
it didn't work. I'll have to try again.

"you are a very nutty person, it is very naughty to use framed page
!"

Yes, I know! I'm feeling nuttier all the time! But the frames are for
a specific purpose - it's not going on a web site, just to selected
computers that are pulling the web page to the desktop from a file
server. I'm trying to avoid having to edit the page every day. :-}

Thanks,
Carol

Dec 6 '06 #3
Well, it took a little tweaking, but it finally works. Here's the
whole thing:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Current Program Frames</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<script type="text/javascript">
//<![CDATA[

// get current day from local computer and set as a variable
var dtNow = new Date();
dtNow = dtNow.getDay();

function change_page1(){

// find the page
var page = '';
switch(dtNow) {
case 0: page = 'Sunday'; break;
case 1: page = 'Monday'; break;
case 2: page = 'Tuesday'; break;
case 3: page = 'Wednesday'; break;
case 4: page = 'Thursday'; break;
case 5: page = 'Friday'; break;
default: page = 'Saturday'; break;
}
return page;
}
function change_page2(){

// find the page
var page = '';
switch(dtNow) {
case 0: page = 'Monday'; break;
case 1: page = 'Tuesday'; break;
case 2: page = 'Wednesday'; break;
case 3: page = 'Thursday'; break;
case 4: page = 'Friday'; break;
case 5: page = 'Saturday'; break;
default: page = 'Sunday'; break;
}
return page;
}

onload=function(){parent.frameday2.location = change_page2()+'.html';
parent.frameday1.location = change_page1()+'.html'}
//]]>
</script>

<frameset rows="50,*" border="none">
<frame name="currentProgs" src="CurrentProgs.html"/>
<frameset cols="395,395" border="none">
<frame name="frameday1">
<frame name="frameday2">
</frameset>
</frameset>
</html>

Thanks for your help! Now I can do all the changes a week at a time
instead of daily! This is actually just a temporary fix until I can
get something up with PHP or Rails.

Carol
Qui a aussi un vieux Mac, vraiment dépassé, mais qui a aussi le Linux
sur le Mac!
Who also has an old Mac, really outdated, but who also has Linux on the
Mac!

Dec 7 '06 #4
ASM
Be*******@gmail.com a écrit :
Well, it took a little tweaking, but it finally works. Here's the
whole thing:
an other way (bp + simple et direct) :

function change_page() {
var dtNow = new Date();
dtNow = dtNow.getDay();
var week = ['Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday','Sunday'];
parent.frameday1.location = week[dtNow]+'.html';
parent.frameday2.location = week[+1+dtNow]+'.html';
}

onload = change_page;

Ou même :

onload = function() {
var dtNow = new Date();
dtNow = dtNow.getDay();
var week = ['Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday','Sunday'];
parent.frameday1.location = week[dtNow]+'.html';
parent.frameday2.location = week[+1+dtNow]+'.html';
}
[a parte french]
Carol
Qui a aussi un vieux Mac, vraiment dépassé, mais qui a aussi le Linux
sur le Mac!
J'ai une Debian en 5 ou 6 CDs sur l'étagère ...
Ouvert un CD ... rien compris ... des tas de readme qui se mordent la
queue les uns les autres ... :-(
On m'a aussi filé une live (de unbuktu ?) ... faudra tt de même qu'un
jour je prenne le temps.
[/ a parte]
Who also has an old Mac, really outdated, but who also has Linux on the
Mac!
My DD is filled up ... no more room.
I hate command lines.
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 7 '06 #5
In comp.lang.javascript message
<45**********************@news.orange.fr>, Wed, 6 Dec 2006 22:35:27, ASM
<st*********************@wanadoo.fr.invalidwrote :
>function change_page(){
// get current date from local computer and set as a variable
var dtNow = new Date();
dtNow = dtNow.getDay();
// find the page
var page = '';
switch(dtNow) {
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
case 0: page = 'Sunday'; break;
case 1: page = 'Monday'; break;
case 2: page = 'Tuesday'; break;
case 3: page = 'Wednesday'; break;
case 4: page = 'Thursday'; break;
case 5: page = 'Friday'; break;
default: page = 'Saturday'; break;
}
return page;
}
var X = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"]

function NewPage() { return X[new Date().getDay()] + "day.html" }

The OP could economise by naming the pages Day0.htm ... Day6.htm, then

function NewPage() { return "Day" + new Date().getDay()+ ".htm" }

no longer needs X.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.com/faq/ Old RC FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 7 '06 #6

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

Similar topics

1
by: Martin | last post by:
There seems to be some strange behaviour when trying to get the scrollHeight and scrollTop of an iframe in IE6. I have tried several ways of getting these values when the iframe is written into...
8
by: cool2005 | last post by:
I tried to dynamically add/clone a <tr> from an existing <tr> to a <table> but the problem is that I need to have a "onclick" event handler in the <tr>. I have tried following A. approach...
3
by: mlybarger | last post by:
i have a popup window that's built from javascript with something like: source += "<html>"; source += " <head>"; source += " </head>"; source += " <frameset rows='100,*'>"; source += " <frame...
2
by: christine.nguyen | last post by:
Hello all, I have a page called test.html. Within test.html I have an iframe whose source is mypage.html. When mypage.html loads, it dynamically creates a javascript element which contains a...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
1
by: Grant | last post by:
Hi, I am looking for a tip. I have a panel and a checkbox. When I check the checkbox, I would like to add buttons to the panel (dynamically). When the checkbox is unchecked, the buttons should...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
2
by: Andy | last post by:
I want to dynamically update a list of elements shown as a checkbox list. A file is used to store the elements, and elements can be added and deleted from the list. The trouble is that the window...
5
by: Yun | last post by:
I have a frameset initially loaded to a page <frameset id=SV name=SV></frameset> Now I want to use JavaScript to dynamically add frames to this frameset. I have tried to use code like...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.