Forum Moderators: open

Message Too Old, No Replies

URL variables for window.open?

Trying to have different URL for each day of year

         

jtwhitacre

5:11 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



I need to substitute a different URL for the window.open statement in javascript for each day of the year.

I created an array for this and it works fine using document write.

Here's the current code I'm using for document.write method.
if (now.getMonth() == 9) document.write("<left>" + Oct[now.getDate()] + "</left>")
if (now.getMonth() == 10) document.write("<left>" + Nov[now.getDate()] + "</left>")

etc.

Anyway, is there a way to substitute a url reference into the window.open statement.

Any help or direction would be greatly appreciated.

Rambo Tribble

1:49 pm on Oct 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



var fil_nam="../fileName.htm";
window.open(fil_nam,"","")

jtwhitacre

10:22 pm on Oct 31, 2004 (gmt 0)

10+ Year Member



Thanks for the help...it did get me going in some direction. I'm rather new to Javascript so I'm probably missing something very obvious.

I've now gotten the window to "popup", however I don't seem to be able to pass the html variable for each day.

Here's what I got going on:

I have the array for every day of the year by month in the head section of my html (actually I'm calling the .js file like this <script language="JavaScript" src="/dailyarray.js"></script>. The file looks basically like this (shortened here for obvious reasons):

<script language="JavaScript">
today = new Date

Jan = new Array
Jan[1] = "with the html address"
Jan[2] = "with the html address"
Jan[3] = "with the html address"
Jan[4] = "with the html address"
Jan[5] = "with the html address"
Jan[6] = "with the html address"
Jan[7] = "with the html address"
Jan[8] = "with the html address"
Jan[9] = "with the html address"
Jan[10] = "with the html address"
Jan[11] = "with the html address"
Jan[12] = "with the html address"

</script>

And then also in the header I have a file reference for the function included so I can reference by a click. Here is the function:
function readtoday()
{
if (today.getMonth() == 0){
var January = (Jan[today.getDate()]);
todayWindow = window.open("January","today","fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=800,height=620");
todayWindow.focus();}
if (today.getMonth() == 1){
var February = (Feb[today.getDate()]);
todayWindow = window.open("February","today","fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=800,height=620");
todayWindow.focus();}
}

Like I said, this is popping the new window OK, but is not passing the html variable.

Any suggestions? I'm pretty much baffled at this point.

Rambo Tribble

2:08 am on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See if this helps:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var now=new Date();
var mo=now.getMonth();
var da=(now.getDate()-1);
var mo_da=new Array(12);
mo_da[0]=new Array(31);
mo_da[1]=new Array(28);
mo_da[2]=new Array(31);
mo_da[3]=new Array(30);
mo_da[4]=new Array(31);
mo_da[5]=new Array(30);
mo_da[6]=new Array(31);
mo_da[7]=new Array(31);
mo_da[8]=new Array(30);
mo_da[9]=new Array(31);
mo_da[10]=new Array(30);
mo_da[11]=new Array(31);

mo_da[9][30]="http://www.webmasterworld.com/forum83/"; //October 31 URL
mo_da[10][0]="http://www.webmasterworld.com/forum91/"; //November 1 URL

</script>
</head>
<body>
<p>
<a href="#" onclick="window.open(mo_da[mo][da],'','height=300px,width=400px')">Open window</a>
</p>
</body>
</html>

jtwhitacre

3:09 am on Nov 1, 2004 (gmt 0)

10+ Year Member



Thanks Rambo...that one got it for me...exactly what I was trying to do...you're the man.