views:

40

answers:

3

Hi..

We all have come across web pages which take some time to show the content the user is waiting for and in the mean time display ads on the page.

I'm not talking about the pages that show full-page ad with 'skip this ad' button.

A typical example of what I'm referring to is: I visit a free plugin site. Click on the plugin I want to download it opens a new page which has the link to the plugin zip file. But the link does not appear immediately. When the page is loaded it is full of ads with other misleading (:P) download links. The actual link I'm interested in appears after say some 5 seconds, squeezed between two ads.

How can this be done for a PHP based website? Will a simple sleep() or usleep() do?

+1  A: 

With a setTimeout() in javascript to make a <div> containing the link visible after some amount of time.

Don
+2  A: 

No.

When you issue a sleep() or a usleep() in a server side language (PHP) the sleep occurs on the server side, typically before output is sent to the user.

You would need to implement the functionality you desire using Javascript and the setTimeout() function.

hobodave
While this is true, one has to wonder if we should be informing others how to perform such shady practices.
Mark
+2  A: 

You can have the link in a div and hide it initially and start a Javascript timer to show it.

Something similar to what you are looking for.

Something is hidden
<div id="hid" style="visibility: hidden">TADA!</div>
here
<script type="text/javascript">
function showIt() {
  document.getElementById("hid").style.visibility = "visible";
}
setTimeout("showIt()", 1000); // after 1 sec
</script>

Source

Shoban