Advanced JavaScript for Reputation

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
I'm working on something involving hosting advertisements, and I need several things:

1. Something that tells the server when an ad has been on screen for 2 or more seconds (the exact time is not necessary)

2. Something to tell the server when an ad gets clicked on

3. A picture-link that serves as the advertisement.



Reputation points will be handed out for good replies.
 

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
ok thanks. Does AJAX run on all servers?

I will need a way for the ad to work on any server, even a poorly equipped one. One thing I could do is link the JS to the AJAX script on my server, but I'm not sure what the most efficient route would be.
 

B5A5M5

New Member
Messages
4
Reaction score
0
Points
0
AJAX is client side, more or less. It's basically a browser bar, and then you get the response. So if you request a page on your site, such as, test.html, your response text would contain the contents of the file.
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
AJAX consists of a server-side (usually php) and client-side (usually javascript) part. So you only will need a server with php and a user with javascript enabled.
 
Last edited:

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
thats exactly what I wanted to hear. Thank you. I'll start off with AJAX then.

if someone could give me a script though, I'd probably pay credits.

(marshian, I tried to give you rep, but it says spread some around first *roll*)



More things: I've been looking at google ads and wondering how they do it 12 lines of code. Does anyone have a deeper explaination?
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
You can do it in one line of code! Just put all code on one line...
(I've heard that before, I'm just too popular ;p)
 

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
:slap:
Edit:
I got the ajax end working, but now I need the JS that will activate stuff onclick and after 2 seconds of being on screen. Can anybody give me a tag or function that might do that?
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
Javascript execution after a fixed period is done using setTimeout(). eg:
Code:
document.onload = setTimeout(dostuff, 5000);
function dostuff() {
  //Gets executed 5 seconds after page load
}

This example should work if i'm not mistaking

Onclick is just adding the onclick field to a html element. Many of them support this event. eg:
Code:
<img src="http://forums.x10hosting.com/programming-help/image.png" alt="" onclick="javascript:dostuff()" />
<script language="javascript">
function dostuff() {
  //Gets executed when the user clicks the image.
}
</script>
 
Top