Reply
What's up this this Javascript?
Old 05-17-2005, 09:58 PM What's up this this Javascript?
Experienced Talker

Posts: 34
What's wrong with this javascript? When I view the page from my computer, it functions fine... But when I upload it...Nothing!

I call a javascript file in each page of the site. Here is how I call it:

HTML Code:
<body>
<p>
  <script language="JavaScript" src="header.js"></script>
In the same directory as the page, is this header.js file:

Code:
document.write("<center><table><tr height='25'><td></td></tr><tr><td><img src='../images/universal/banner.gif'></td></tr></table>")
document.write("<table bgcolor='ddddd'><tr><td width='157'><center><font face='Verdana, Arial, Helvetica, sans-serif' size='2'><a href='about.htm'>about</a></font></center></td><td width='157'><center><font face='Verdana, Arial, Helvetica, sans-serif' size='2'><a href='login.htm'>log-in</a></font></center></td><td width='157'><center><font face='Verdana, Arial, Helvetica, sans-serif' size='2'>register</font></center></td><td width='157'><center><font face='Verdana, Arial, Helvetica, sans-serif' size='2'><a href='blog.htm'>announcements/blog</a></font></center></td><td width='157'><center><font face='Verdana, Arial, Helvetica, sans-serif' size='2'>dev forums</font></center></td></tr></table></center>")
document.write("<table><tr height='5'><td></td></tr></table>")
document.write("<table align='center' bgcolor='dddd99'><tr><td width='800'>")
Like I said - Works great on my own computer. Once uploaded (Same file structure, etc) it no longer works...
mtairhead is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-18-2005, 12:38 AM
desertland's Avatar
Skilled Talker

Posts: 86
I was able to get it to work without any problems. You can try looking at the header.js file directly (type the path to it in the address bar) to make sure it's there. If that works, try setting the 'src' attribute to the full URL of the header.js file instead of just 'header.js'.
__________________
I store my recipes online (the way nature intended) at www.meanmeals.com
desertland is offline
Reply With Quote
View Public Profile
 
Old 05-18-2005, 08:12 AM
Novice Talker

Posts: 13
Location: Sydney Australia
if you want to test that your javascript file is downloading then just put this in the first line:

alert("Yippee! My file is in the right place!");

if a message box doesn't popup then you've got the path wrong.

the alert box helps with testing almost anything.
rimian is offline
Reply With Quote
View Public Profile Visit rimian's homepage!
 
Old 05-18-2005, 09:39 AM
Experienced Talker

Posts: 34
Thank you!

I've taken both of your suggestions:
I loaded just the .js file in Firefox (And in IE) by using the file's complete URL and I also inserted the "alert" statement into the first line... It all works out, but only after I take out the first line of the script!

I decided after posting the intial request for help to do a little testing, and it turns out that once I remove the first line of script in the file, everything works great. Here's the line:

Code:
document.write("<center><table><tr height='25'><td></td></tr><tr><td><img src='../images/universal/banner.gif'></td></tr></table>")
When that line is in the javascript file, nothing in the code executes. In fact, when that line is present, I cannot load the .js file with the complete URL (The page is blank - Same URL!) and when I look at the source of the page, there's nothing there!

Does anyone know what's up?

Thanks for your help,

Andrew
Code:
document.write("<center><table><tr height='25'><td></td></tr><tr><td><img src='../images/universal/banner.gif'></td></tr></table>")

Last edited by mtairhead : 05-18-2005 at 09:40 AM. Reason: Correcting the [code] tags
mtairhead is offline
Reply With Quote
View Public Profile
 
Old 05-18-2005, 09:55 AM
Experienced Talker

Posts: 34
Update: It's not that javascript at all! The path to the image does not display the image! When I attempted to load banner.gif using its entire URL, nothing appeared. This annoys me, because I know the URL is correct. I've gone over it several times.

The title of the page is "banner.gif (GIF Image, 32x32 pixels)" - So..The browser does see an image, right??? Why can't I?
mtairhead is offline
Reply With Quote
View Public Profile
 
Old 05-18-2005, 10:43 AM
chrishirst's Avatar
Super Moderator

Posts: 15,313
Location: Blackpool. UK
do you have XP with SP2 by some chance? because you are describing the behaviour of the ad blocker and the file is the correct size.

It won't block from the local drive but it does block when served up as a URI.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-18-2005, 04:57 PM I do, in fact...Just got SP2 a few weeks ago.
Experienced Talker

Posts: 34
Oh I can't believe it. It was the freaken name of the file. Your post about ads made me think of it... It's just a main menu..Not an ad...But I named it "Banner.gif"...What was I thinking... If anything's an ad, it's going to be the file named "banner", and so of course Firefox blocked it.

Thanks,

Andrew
mtairhead is offline
Reply With Quote
View Public Profile
 
Old 05-18-2005, 09:15 PM
Novice Talker

Posts: 7
lol. Wow complicated!!!
dave123 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to What's up this this Javascript?
 

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14668 seconds with 12 queries