|
kahlan
|
 |
« on: October 27, 2001, 01:12:00 PM » |
|
I created a great little javascript that loads a random banner advertising different parts of my site at the top of each of my pages. It was pretty much the first javascript I'd every written completely by myself! I'm pretty proud of it. If you're interested in looking at the result visit my page. If you want to use the code I can post it if you want (cause it was a bit tricky to get to work properly) and you can use it on your site if I'm credited with it and you include a link to me http://www.lunarpages.com/dragongirl/
|
|
|
|
|
Logged
|
|
|
|
|
amy
|
 |
« Reply #1 on: October 27, 2001, 01:39:00 PM » |
|
That's terrific!
|
|
|
|
|
Logged
|
--Amy Armitage Lunarpages.com
|
|
|
|
calamityJ
|
 |
« Reply #2 on: October 28, 2001, 07:05:00 AM » |
|
Good show, Kahlan. It reminds me of that day when I figured out how to have rotating quotes on my homepage. Except I stole the code from Amber's page. So I'm clearly a not-from-scratch kind of girl, unlike you!
|
|
|
|
|
Logged
|
|
|
|
|
kahlan
|
 |
« Reply #3 on: October 28, 2001, 01:16:00 PM » |
|
Thankyou  Usually I look at other peoples code and work out how they did things so I can make it do what I want it to do, but this time I started from scratch because I'd never seen banner adds with javascript before. Learning C has been a great help with Javascript. Its very similar code. I was so proud of myself when i got it working that I made my friends look at it straight away!!  heh heh... I don't think they really understood the blood sweat and tears that had gone into it for about an hour and a half though...
|
|
|
|
|
Logged
|
|
|
|
|
Santos
|
 |
« Reply #4 on: October 28, 2001, 01:50:00 PM » |
|
That is really neato script and i definatelly give ya props, ya wrote the whole thing yourself. Great work.
|
|
|
|
|
Logged
|
Smile, it makes people wonder what you're up to...
|
|
|
|
Max
|
 |
« Reply #5 on: October 29, 2001, 01:05:00 AM » |
|
Want to write a script for lunarpages like that only shows one pop behind a day, but randomly? i hope you all noticed our new advertising policy.. with minimal ads.. but then.. one big sucker every 24 hours, that is only popped once 
|
|
|
|
|
Logged
|
|
|
|
|
Rıan_
|
 |
« Reply #6 on: October 29, 2001, 04:58:00 PM » |
|
can you post the scipt?
because thats so cool, i wouldnt mind using it and giving you props on my site for it
|
|
|
|
|
Logged
|
Hi! I'm a .signature *virus*! Copy me into your ~/.signature to help me spread!
|
|
|
|
kahlan
|
 |
« Reply #7 on: October 29, 2001, 01:21:00 PM » |
|
MAX: I guess it could be done... I have a couple of ideas of how I would have to change it, however it will take some testing and as I'm still teaching myself this whole javascript thing it might take a little bit of thinking... (hmm... my brain starts to churn away again...)
|
|
|
|
|
Logged
|
|
|
|
|
kahlan
|
 |
« Reply #8 on: October 29, 2001, 01:52:00 PM » |
|
The following code goes into a file called advert.js // Advert (c) 2001 Kahlan Amnell - dragongirl@softhome.net// Script created for Dragon Girl's Realm - http://www.lunarpages.com/dragongirl/ // This script may not be reproduced without permission // these arrays contain the link locations and image locations for your adverts var page=new Array( " http://www.lunarpages.com/dragongirl/magick/campaign.html", " http://www.lunarpages.com/dragongirl/guilds/wc101.html", " http://www.lunarpages.com/dragongirl/magick/crafty/index.html", " http://www.lunarpages.com/dragongirl/magick/symbol.html", " http://www.lunarpages.com/dragongirl/magick/wisdom.html", " http://www.lunarpages.com/dragongirl/folktales/index.html", " http://www.lunarpages.com/dragongirl/magick/reading.html", " http://www.lunarpages.com/dragongirl/dragons/horde.html", " http://www.lunarpages.com/dragongirl/guilds/index.html", " http://www.lunarpages.com/dragongirl/magick/crafty/runes.html", " http://pub2.bravenet.com/forum/show.php?usernum=134432163" ); var image = new Array( " http://www.lunarpages.com/dragongirl/images/campaign.gif", " http://www.lunarpages.com/dragongirl/images/wc101.gif", " http://www.lunarpages.com/dragongirl/images/crafty.gif", " http://www.lunarpages.com/dragongirl/images/symbols.gif", " http://www.lunarpages.com/dragongirl/images/wisdom.gif", " http://www.lunarpages.com/dragongirl/images/fairytales.gif", " http://www.lunarpages.com/dragongirl/images/reading.gif", " http://www.lunarpages.com/dragongirl/images/horde.gif", " http://www.lunarpages.com/dragongirl/images/guilds.gif", " http://www.lunarpages.com/dragongirl/images/runes.gif", " http://www.lunarpages.com/dragongirl/images/forum.gif" ); // change the end number in this variable to the number of adverts you have -1 var pagenum = Math.round(Math.random()*10); function advert() { window.location = page[pagenum]; } function get_image(imgName) { document[imgName].src= image[pagenum]; } The following is code that must be placed in your html file... I've had a bit of trouble posting the required html code here, but I will try again... The following code must go inbetween your HEAD tags: <SCRIPT LANGUAGE="JavaScript1.2" SRC="advert.js"></SCRIPT> I'm having trouble getting the forum to let me add this tag, so I'll have to explain it in a different way... You need the 'onload' command included in your BODY tag and following the 'onload' command put this: ="javascript:get_image('advert')" And create a blank image the same size as your adverts as this image will be changed with the onload command in your BODY tag. This is the only way I could get the advert to load. This is the code for your blank image: <A HREF="javascript:advert()"><IMG SRC="images/blank.gif" name="advert" height="56" width="244" border=0></A> Ok... hopefully this forum will like me this time and will let me post this... If you have any problems just yell  If you use the code the comments at the top of the js file must remain intact and I'd like to have a link back to my site or at least some form of credit on your site that I wrote the code.
|
|
|
|
|
Logged
|
|
|
|
|
Santos
|
 |
« Reply #9 on: October 29, 2001, 04:38:00 PM » |
|
In that code i did not see any timer code. What is it that you wanted Max, one popup per 24 hrs + image swapper? Kahlan that is great script for first complete try  amazing.
|
|
|
|
|
Logged
|
Smile, it makes people wonder what you're up to...
|
|
|
|
kahlan
|
 |
« Reply #10 on: October 29, 2001, 08:08:00 PM » |
|
Thanks  That is the code that I use on my page. I still have to find a bit of spare time to attempt Max's request... (I have 2 programming assignments due  )
|
|
|
|
|
Logged
|
|
|
|
|
Max
|
 |
« Reply #11 on: October 29, 2001, 11:36:00 PM » |
|
Want something like we allready have on http://www.lunarpages.com/ad.js only that it should be a rotation of diffrent pop unders every 24 hours.. popped once as in the .js code above. Right now we use cookies to keep track of that.
|
|
|
|
|
Logged
|
|
|
|
|
Rıan_
|
 |
« Reply #12 on: October 29, 2001, 11:43:00 PM » |
|
WAHOO! *bounces up and down* Good for free lunar page members who cant use CGI
|
|
|
|
|
Logged
|
Hi! I'm a .signature *virus*! Copy me into your ~/.signature to help me spread!
|
|
|
|
kahlan
|
 |
« Reply #13 on: October 30, 2001, 02:26:00 PM » |
|
I've been thinking about your 'challenge' Max and I'm not sure how it could be done except by using a cookie or some form of storage on your server. I haven't got that advanced in my programming yet (apart from my amazing html skills  ) so I don't think I can help you out.
|
|
|
|
|
Logged
|
|
|
|
|
Max
|
 |
« Reply #14 on: October 30, 2001, 09:58:00 PM » |
|
Have to do it myself then 
|
|
|
|
|
Logged
|
|
|
|
|