PDA

View Full Version : Script like google Ads needed. to display random HTML code.



chetanmadaan
06-23-2008, 07:00 PM
Hi,

I owe a website... a quite popular one.. and i want a script which can display different Javascript ad codes randomly like... i saw and random image script to display random images but i didn't find any for displaying random HTML code or Javscript code...

Thanks in Advance!

magicyte
06-23-2008, 07:44 PM
Here is a small code I developed. For any other viewers, please notify if there are any errors.


<html>
<head>
<title>
NONE
</title>
<script language="JavaScript">
function load_differ()
{
var numb = Math.round(Math.random()*3-.5);
document.getElementById('frame').src="ad_num_"+numb+".html";
}
</script>
</head>
<body onload="load_differ()">
<iframe width="200" height="125" src="none.html" id="frame">
</iframe>
</body>
</html>

Hope it gives you an idea of what you'll need. Oh, and you can edit the code. You also might want to create three HTML files with the names of "ad_num_0.html", "ad_num_1.html", and "ad_num_2.html". You are welcome in advance. Any questions or code requests? E-mail me: magicyte.programmer@gmail.com

-magicyte

chetanmadaan
06-23-2008, 09:02 PM
two problems what i think...
ad_num_0.html, 1 and 2 are not listed in the script... the files will be in the same directoy or other... can you create them and send me as a attachment and i will just edit the Html ad files?/

thanks!

magicyte
06-24-2008, 03:24 AM
What I meant by creating those HTML files ... those files SHOW YOUR ADS that you will be showing ... you just make your own little advertisements and maybe put a cute little link to some place. Also: You can reduce the number of ad pages by changing the 3 on line 9, char 37 ...

<html>
<head>
<title>
NONE
</title>
<script language="JavaScript">
function load_differ()
{
var numb = Math.round(Math.random()*3-.5);
document.getElementById('frame').src="ad_num_"+numb+".html";
}
</script>
</head>
<body onload="load_differ()">
<iframe width="200" height="125" src="none.html" id="frame">
</iframe>
</body>
</html>
... to any other number to display different html pages. Of course you would need to create more html pages with the name ad_num_(some integer).html. Just saying that you will need to create those files needed. Oh, by the way... would you mind letting the people on your website know that an eleven year old boy made the code? Of course it's illegal to use other people's codes without leaving the notice saying that you must leave the notice in the code, or else. Could you just let them know? Please. Plz. Thanx if you do. By the way... what website do you own? Maybe I will let people know about it if you do what I asked. Actually, I will! Well, 'tis a pleasure doing business with you! E-mail me magicyte.programmer@gmail.com if you have any concerns, comments, or problems. I can also whip up some more code for you if you wish... Also, would you mind thanking me one more time, just to get my reputation up? Thanx! Anyway, you are welcome for everything!

-magicyte

P.S. - Here is a sample code for ad_num_0.html:


<html>
<head>
<title>
Ad 1
</title>
<script language="JavaScript">
function red(obj)
{
obj.style.color="red";
}

function blue(obj)
{
obj.style.color="blue";
}
</script>
</head>
<body>
<a style="font-family:Courier New;font-size:14px;color:blue;cursor:hand;" onmouseover="red(this)" onmouseout="blue(this)" onclick="red(this)" href="http://www.jimswarehouse.com/" target="_top">
Jim's Warehouse
</a>
Buy stuff today at Jim's Warehouse! You get lots for less!
</body>
</html>

I figured you could duplicate it, change it up, and use it for the other ad pages. Hope it helps!

chetanmadaan
07-01-2008, 11:51 PM
but how about creating none.html or something it is showing up error for none.html please check here...
http://dloadmp3.com/ads_Check/

magicyte
07-02-2008, 02:29 AM
First of all, none.html DOES NOT EXIST. You are to make your own HTML page called none. And that is not even why there is an error there is an error because when it took numb, the variable, there was something wrong with it. You changed up the code, it appears. This is the original code:


<html>
<head>
<title>
NONE
</title>
<script language="JavaScript">
function load_differ()
{
var numb = Math.round(Math.random()*3-.5);
document.getElementById('frame').src="ad_num_"+numb+".html";
}
</script>
</head>
<body onload="load_differ()">
<iframe width="200" height="125" src="none.html" id="frame">
</iframe>
</body>
</html>

and this, my friend, is the warped code (the changed up code):


<html>
<head>
<title>
NONE
</title>
<script language="JavaScript">
function load_differ()
{
var numb = Math.round(Math.random()**3*-.5);
document.getElementById('frame').src="ad_num_"+numb+".html";
}
</script>
</head>
<body onload="load_differ()">
<iframe width="200" height="125" src="none.html" id="frame">
</iframe>
</body>
</html>

Look at the warped code carefully and compare it with the original code. Any differences? The problem is highlited in the next code. Its coordinates are found at LINE 9, CHARACTERS 36 and 39:


1: <html>
2: <head>
3: <title>
4: NONE
5: </title>
6: <script language="JavaScript">
7: function load_differ()
8:
9: var numb = Math.round(Math.random()**3*-.5);
10: document.getElementById('frame').src="ad_num_"+numb+".html";
11: }
12: <script>
13: </head>
14: <body onload="load_differ()">
15: <iframe width="200" height="125" src="none.html" id="frame">
16: </iframe>
17: </body>
18: </html>

The highlited part is your problem. It should be

var numb = Math.round(Math.random()*3-.5);

and NOT

var numb = Math.round(Math.random()**3*-.5);

But that is just the beginning. I was wondering if you had even uploaded the other HTML files named ad_num_0.html, ad_num_1.html, and ad_num_2.html. If you hadn't, then please do so. If you hadn't created the HTML files, please do so. If you hadn't created a blank HTML page named none.html, please do so. Everything should be solved. You may PM or e-mail me by using the links in my signature. Hopefully all of my help helped.

-magicyte

chetanmadaan
07-02-2008, 06:21 AM
Thanks for that.... Its works perfectly fine now...

Good Work!

magicyte
07-03-2008, 03:14 PM
You are very welcome for all of the help I gave you. If you have any more questions on ANYTHING, please, feel free to PM me or e-mail me using the links in my signature. By the way... I am a young boy. If you wish to have me help you with any professional projects, reassure yourself for complete satisfaction. Even so, I am an experienced programmer, and I can help you with a lot. Simply ask.

-magicyte