Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Banner Ads & Frames

Banner Ads & Frames
Thread Tools
Fresh-Faced Recruit
Join Date: Sep 2002
Status: Offline
Reply With Quote
Apr 19, 2004, 01:29 AM
 
Perhaps somebody can help me solve a few problems I'm having with my new website: http://www.hzfilms.com/

I have banners at the top of the page that are set to lead to content that I would like to display in the middle of three frames. When the banners are clicked, they open the content in a window of its own, without the top or bottom frames. What code could I use to force the banners to open content in the middle of the three frames, not in a window all alone?

Also, any reason why my banner rotation script is not choosing banners at random?

Thanks.
     
jherz  (op)
Fresh-Faced Recruit
Join Date: Sep 2002
Status: Offline
Reply With Quote
Apr 19, 2004, 10:14 PM
 
Originally posted by jherz:
I have banners at the top of the page that are set to lead to content that I would like to display in the middle of three frames. When the banners are clicked, they open the content in a window of its own, without the top or bottom frames. What code could I use to force the banners to open content in the middle of the three frames, not in a window all alone?
Nobody? Is there a way I can rethink my website so that it doesn't use frames but functions the same way? What would be the best alternative?
     
Mac Elite
Join Date: May 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Apr 19, 2004, 10:22 PM
 
Okay, each frame has a 'name' on your website. The top frame is called 'top', middle is called 'content' and the bottom is called 'navi'. I am assuming you gave them these names yourself.

So if your banner add links to this address:

http://www.hzfilms.com/content/films/truth/index.html

If you want it to only appear in the middle frame, change your code from:

Code:
<a href="content/films/truth/index.html">
To this:

Code:
<a href="content/films/truth/index.html" target="content">
The target code will tell the browser which frame to load the content in. Hope that helps
     
jherz  (op)
Fresh-Faced Recruit
Join Date: Sep 2002
Status: Offline
Reply With Quote
Apr 19, 2004, 10:57 PM
 
Originally posted by thePurpleGiant:
The target code will tell the browser which frame to load the content in. Hope that helps
I tried that and it doesn't work. It may be because the banner rotation is javascript... When I put a target in, the banners no longer rotate and clicking on them does nothing. Very weird.

Here is the code:

i = 9 // Number of banners that you have
banner1 = new Image();
banner1.src = "images/bb1.jpg";
banner2 = new Image();
banner2.src = "images/dh2.jpg";
banner3 = new Image();
banner3.src = "images/ub3.jpg";
banner4 = new Image();
banner4.src = "images/bb3.jpg";
banner5 = new Image();
banner5.src = "images/dh3.jpg";
banner6 = new Image();
banner6.src = "images/ub4.jpg";
banner7 = new Image();
banner7.src = "images/dh1.jpg";
banner8 = new Image();
banner8.src = "images/ub2.jpg";
banner9 = new Image();
banner9.src = "images/bb2.jpg";

links = new Array
links[1] = "../content/films/baby/index.html"
links[2] = "../content/films/delhi/index.html"
links[3] = "../content/films/truth/index.html"
links[4] = "../content/films/baby/index.html"
links[5] = "../content/films/delhi/index.html"
links[6] = "../content/films/truth/index.html"
links[7] = "../content/films/delhi/index.html"
links[8] = "../content/films/truth/index.html"
links[9] = "../content/films/baby/index.html"

description = new Array
description[1] = "Baby Eat Baby"
description[2] = "Delhi House"
description[3] = "Baby Eat Baby"
description[4] = "Baby Eat Baby"
description[5] = "Delhi House"
description[6] = "The Unbelievable Truth"
description[7] = "Delhi House"
description[8] = "The Unbelievable Truth"
description[9] = "Baby Eat Baby"

function randombanner(){
var randomnumber = Math.random();
i = Math.round( (i - 1) * randomnumber) + 1;
document.banner.src = eval("banner" + i + ".src");
}

function startTime(){

var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;
closeTime+=7;
Timer();

}

function Timer(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
curTime=hours*3600+mins*60+secs
if (curTime>=closeTime){
if (i < 9){
i++;
document.banner.src = eval("banner" + i + ".src");
}
else{
i = 1;
document.banner.src = eval("banner" + i + ".src");
}
startTime();
}
else{
window.setTimeout("Timer()",1000)}

}

function clickLink(){
top.location = links[i]
}

function descript(){
window.status = description[i]
}
     
Moderator
Join Date: Mar 2004
Location: Copenhagen
Status: Offline
Reply With Quote
Apr 20, 2004, 08:24 AM
 
I didn't really read through the script properly, just quickly scanned it...

But from a glance, it would seem that you should change the "top.location = ..." in the clickLink() function to "content.location = ..."

I think that should do it, shouldn't it?

Edit: Also, two little comments:

1) I'm not sure, but isn't the "return true;" after calling the onClick event superfluous?

2) I would make the bright blue text colour a little less bright - it's barely readable... just a few notches darker would make a big difference...
(Last edited by Oisín; Apr 20, 2004 at 08:30 AM. )
     
jherz  (op)
Fresh-Faced Recruit
Join Date: Sep 2002
Status: Offline
Reply With Quote
Apr 20, 2004, 09:28 AM
 
Originally posted by Oisín:
I didn't really read through the script properly, just quickly scanned it...

But from a glance, it would seem that you should change the "top.location = ..." in the clickLink() function to "content.location = ..."

I think that should do it, shouldn't it?

Edit: Also, two little comments:

1) I'm not sure, but isn't the "return true;" after calling the onClick event superfluous?

2) I would make the bright blue text colour a little less bright - it's barely readable... just a few notches darker would make a big difference...
Thanks! Changing the clicklink() to "content.location" fixed the problem (but only in Safari). Oddly enough, when I tested it in Explorer clicking on a banner does nothing now. Why would it work in Safari but not Explorer?

As for the text color, this is something that works right in Explorer but not in Safari. Links are supposed to be grey and only turn blue on mouseover. No idea why this doesn't render right in Safari.
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Apr 20, 2004, 10:58 AM
 
Does
Code:
top.document.frames("content").location or top.document.frames("content").document.location.href
work?

I'm surprised content.location worked at all....

Also, there always seems to be a bunch of ways to change the location of a frame - I can never remember which is the best... Anyone know if the frames collection been depreciated?
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
jherz  (op)
Fresh-Faced Recruit
Join Date: Sep 2002
Status: Offline
Reply With Quote
Apr 20, 2004, 11:27 AM
 
Originally posted by Black Book:
Does
Code:
top.document.frames("content").location or top.document.frames("content").document.location.href
work?

I'm surprised content.location worked at all....

Also, there always seems to be a bunch of ways to change the location of a frame - I can never remember which is the best... Anyone know if the frames collection been depreciated?
That top one did the trick. It works now, even in IE. Thanks.

What do you mean about the frames collection being depreciated? Are frames frowned upon? Is there an alternative I could use that would allow my site to function the same way?
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Apr 20, 2004, 12:56 PM
 
What I meant by it being depreciated is that I don't know whether you should use document.frames or document.getElementsByTagName("frame")[index] or document.getElementById("frame_id") etc... (from within the page with the frameset)

I'll go over to the w3c and have a look myself - just being lazy. I haven't used frames in years, so I can never remember how to reference them.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
jherz  (op)
Fresh-Faced Recruit
Join Date: Sep 2002
Status: Offline
Reply With Quote
Apr 20, 2004, 02:41 PM
 
Originally posted by jherz:
That top one did the trick. It works now, even in IE. Thanks.
I spoke too soon. It only works in IE. Now Safari does not work right. Damn.
     
Moderator
Join Date: Mar 2004
Location: Copenhagen
Status: Offline
Reply With Quote
Apr 20, 2004, 11:32 PM
 
There is one of these ways that works everywhere... but like BB, I can't remember which one it is either...

Actually, I don't think I've ever had compatibility problems just using top.content.location.href - are you sure that's not it?

Edit: Oh, reading my previous post, I see I was being very sloppy when writing it... (too tired I guess)...

When I wrote content.location, I of course meant top.content.location.href, just seemed to forget a few parts...
     
Moderator
Join Date: Mar 2004
Location: Copenhagen
Status: Offline
Reply With Quote
Apr 21, 2004, 12:29 AM
 
Oops, double post... an hour apart
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 09:09 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2