What's my damage?

This is a discussion on "What's my damage?" within the JavaScript Forum section. This forum, and the thread "What's my damage? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 23rd, 2006, 15:29
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
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: Select all
 <script src="http://www.dhreport.com/javascript_date.js" type="text/javascript"></script>
And in the body I have
Code: Select all
<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: Select all
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: Select all
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.
Reply With Quote

  #2 (permalink)  
Old May 23rd, 2006, 19:55
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: What's my damage?

Mason,

Where exactly are you trying to display it?
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #3 (permalink)  
Old May 23rd, 2006, 22:09
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
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.
Reply With Quote
  #4 (permalink)  
Old May 24th, 2006, 12:52
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #5 (permalink)  
Old May 24th, 2006, 13:24
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: What's my damage?

This is all you need php wise.
Code: Select all
<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.
Reply With Quote
  #6 (permalink)  
Old May 24th, 2006, 13:43
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
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.
Reply With Quote
  #7 (permalink)  
Old May 24th, 2006, 13:48
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
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 13:51.
Reply With Quote
  #8 (permalink)  
Old May 24th, 2006, 21:14
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
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.
Reply With Quote
  #9 (permalink)  
Old May 24th, 2006, 23:43
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
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 - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #10 (permalink)  
Old May 25th, 2006, 16:05
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #11 (permalink)  
Old May 25th, 2006, 16:53
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
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.
Reply With Quote
Reply

Tags
damage

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


All times are GMT. The time now is 04:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43