Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old May 23rd, 2006, 11:29 AM   #1
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
What's my damage?

Total brain breakdown.

I have a simple autodate, one for the date then I added the day of the week.

Inside the html head I have:
Code:
 <script src="http://www.dhreport.com/javascript_date.js" type="text/javascript"></script>
And in the body I have
Code:
<div id="edition_box2">
<script type="text/javascript" 
src="http://www.dhreport.com/javascript_day.js">
</script>, 
<script type="text/javascript" src="http://www.dhreport.com/javascript_date.js">
</script>
        </div>
My problem? The code in the head displays the date at the top of the page, above the body, as well as in the place it's supposed to. It works fine otherwise.

the two .js pages are this old horse I copied:


Code:
function makeArray() {
    for (i = 0; i<makeArray.arguments.length; i++)
        this[i + 1] = makeArray.arguments[i];
}

function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var months = new makeArray('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

var today = new Date();
var date  = today.getDate();
var month = today.getMonth() + 1;
var year  = y2k(today.getYear());

document.write( months[month]+ ' ' + date + ', ' + year);
and this for the day of the week:
Code:
function makeArray() {
    for (i = 0; i<makeArray.arguments.length; i++)
        this[i + 1] = makeArray.arguments[i];
}
function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}
var days = new makeArray0('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

var today = new Date();
var day   = days[today.getDay()];

document.write(day);
This is at Daily Health Report if you need to see it. I get a centered date above the top border, which isn't that unsightly actually, but would be better without it.

Hate being a noob.
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 23rd, 2006, 03:55 PM   #2
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Re: What's my damage?

Mason,

Where exactly are you trying to display it?
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 23rd, 2006, 06:09 PM   #3
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
Re: What's my damage?

Are you in a position to use php? The date function will return the date already formatted according to the string you give it and then you just display it where you want it.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 08:52 AM   #4
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
Re: What's my damage?

Rob, I want to display right below the logo -- this is working fine, I'm just getting an extra display (of the date only, not the day) above the body.

Yes Geoff, I'm actually in the process of learning php/mysql now. But still, I want to understand where I'm going wrong with this simple js script, although afaik it's a problem of referencing external scripts rather than the code. (Even though I will almost certainly end up doing it with php -- when I can write it myself -- since there are people who disable js on their browser.)

I actually woke up last night with the thought, why don't I try putting both scripts in the same .js file? Off to try it now. Thx for the responses.
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 09:24 AM   #5
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
Re: What's my damage?

This is all you need php wise.
Code:
<div id='date'>
   <?php print (date('l jS').'<br />'.date('F Y')); ?>
</div>
The reseason for calling the date function twice with the break in between was an easy way of getting the day and date on one line with the month and year on the second.

Having a ponder over your existing code..

Might be getting ahead of the game here but redering in Firefox completely different to IE.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 09:43 AM   #6
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
Re: What's my damage?

Ok. Got it.

Seperate from where you call the date javascript inside that div, you also call the scripts on lines 32 & 33 before you get to the <body> tag.

It's these two lines that are responsible for the date at the top of the page.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 09:48 AM   #7
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
Re: What's my damage?

Hmmz, I just took the reference completely out of the <head> and everything is fine. I still don't get it though.

Are you saying FF is just different, or is broken? It was easier to lay it out differently in FF and gives me a second view to ponder

PS if you want to see the current version, have a look at my sandbox in IE, Daily Health Report

Last edited by masonbarge; May 24th, 2006 at 09:51 AM..
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 05:14 PM   #8
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
Re: What's my damage?

On the contrary, you should be designing to have it working as you want it in Firefox and then tweak for IE.

Firefox is the more standards compliant browser so should be your primary design goal.

I notice that you are coding to html 4.01 so IE is going to be in quirks mode.

Just had a look at your latest link. Date still showing at top in Firefox and IE. Firefox layout all over the place.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 07:43 PM   #9
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Re: What's my damage?

Mason, I would personally be designing for xhtml 1.0 transitional or strict.

Hell, if this site in all it's vastness can do it....
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 25th, 2006, 12:05 PM   #10
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
Re: What's my damage?

That link wasn't for the home page; it was just a test page I uploaded to check out whether some ideas would render the same on the server. I deleted it; really sorry I ever linked it. The home page is at Daily Health Report, it should be in good shape at least on IE and FF.

Thx for the tips, I'll put redoing it in xhtml on my list. I had no idea it would turn IE quirks mode on, sigh.

I don't agree about FF being more W3c compliant. The biggest sheer pain in the neck for me is FF's inexplicable inclusion of padding, margins and border in the box size. I think IE reads flow better, too. FF is a better browser, especially the gazillion great add-ons available, but IMHO they both suck for standards compliance.

Thx to both of you for the comments. Really has been a lot of help.
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 25th, 2006, 12:53 PM   #11
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
Re: What's my damage?

I don't know which version of Firefox you are using but the layout in Firefox as against IE is completely different.

I'm currently using 1.5.0.3

Both are broken in many different ways.

The way Firefox handles the box model is considered to be, by most, as the way that W3C intended hence its the same in Opera, Safari, etc. Although I have seen it argued that IE's way is more logical.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
damage


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0 RC8