...

View Full Version : How do I add <br> and a link in this script? Am A Newbie



searson1
03-09-2007, 08:53 PM
Hi, I haver this script which works great. I would like to add a <br> command in to add other text as a seperate paragraph and also I would like to include a some text which can also act as a link. Could anyone advise please, I would appreciate your help. I am a complete novice at this stuff.


<script language="JavaScript">
<!--
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var monthname =
new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );
document.write(dayname[day]+", ");
document.write(date+" ");
document.write(monthname[month]+" ");
document.write(+"2007");
// January is month 0
if ((month == 0) && (date == 1)) document.write(" - Mary, Mother of God");
document.write("<br></font>");
//-->
</script>

I have every day of the year, but thought that would be too long to include the whole lot.! LOL!

nikkiH
03-09-2007, 10:53 PM
I'm not sure where you want to inject it, but seems it's just using document.write to make new html. (which is generally not a good thing any more, BTW, it's better to use DOM methods or innerHTML if you can)

document.write("<br>");

That writes the break.
You can just write out <a href='whatever'>link</a> and so on however you like.

Belinea
03-10-2007, 01:43 AM
I'm not sure where you want to inject it, but seems it's just using document.write to make new html. (which is generally not a good thing any more, BTW, it's better to use DOM methods or innerHTML if you can)

document.write("<br>");

That writes the break.
You can just write out <a href='whatever'>link</a> and so on however you like.
Thank you for that. I have one small problem however. How do I fet the link I have created to open out of the Iframe that I have.

To explain, I have the above script in a file called date.htm - I then have an Iframe on my index.htm page that calls the scripts results to go into. That works great. However, when I click on the link that now appears, it opens up in the Iframe on my index.htm page. I would like it to open up in its own page, but without having two pages open at once. I hope that made sense.

Sorry, I am stupid I know!

nikkiH
03-12-2007, 04:17 PM
try: <a href="whatever.html" target="_top">link</a>

the-dream
03-12-2007, 04:21 PM
give your iframe an id then set the target of the link to that id!
i think that makes sense

nikkiH
03-13-2007, 04:28 PM
I think the OP wanted the opposite? For the link to open in the main window, not the iframe?

glenngv
03-13-2007, 04:57 PM
I think the OP wanted the opposite? For the link to open in the main window, not the iframe?
I think so.

<a href="whatever" target="_top">link</a>

nikkiH
03-13-2007, 05:10 PM
Yep, that's what I had.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum