Load advert on click - php

So, I have a HTML page with links to video files on my server. What I need is, when someone clicks on the video links, a script should start loading up the advert from Google Adsense.
And after 10 seconds, it should be automatically redirected to the video file.
How can I do this?
Thanks

I'm sure that goes against the crazy adsense TOS. Read them again before getting banned.

Isn't that illegal?
You need to change the link to the video with a simple text (in ) and add
the "onClick" attribute which will activate a JS function.
<div onClick="javascript:showAdvertAndRedirect('http://www.video.com/id/23233')">Click to see the video</div>
The js function will show the ad (by changing another div's innerHTML)
and will also run a timer of 10 seconds (actually a delay) , eventually will redirect
the visitor to the mentioned url.

Related

How to make my jquery plugin not restart when pressing links in my dynamic php website?

I have a classic php controller that gets the page name from the url and displays that page under my header section where my slideshow lives.Every time a press a link the slideshow restarts from the fisrt photo again or its killed while sliding and image.I know that the cause of that is that everytime time a link is given to the browser all the page is beeing proccesed again .
I know a few ways to go arround the problem using Ajax but the only problem with that is that the url will not change because it will be Async..I want to keep my url so my visitors are able to share the links they want.
An example site is at http://sounds.beatport.com where you press a sample to play , it loads it at the top and then you can browse thru the styles drop down menu changing links but yet the sample keeps playing..
So what i want to achive is having a div with my slideshow plugin keep playing at the top of my site without restarting while the visitors browse thru the site;

Bot friendly ajax page

I'm trying to code a seo friendly ajax portfolio right now. My goal is to provide javascript effects to users and normal html to bots/users without js.
Files:
index.php (starting point of my program)
aboutme.php (contains html code for "about me")
contact.php (contains html code for "contact")
The idea:
User visits index.php and clicks on "About me" -> loading animation appears -> aboutme.php gets loaded with ajax -> history.pushstate rewrites the url to aboutme.php.
-> When the user shares the current website url on fb/twitter/g+ the bots will get the correct title, body etc., as it is the normal html page without any javascript.
But my problem is: If other users open that page, they see directly the content. But I want to show them a loading animation first until the data got loaded with ajax (similar as they click on a link).
How can I achieve such an approach? Thank you very much!
Best way to do this, create a javascript file. Write the link tag into "head" part. This will make the javascript file downloaded before content. Javascript shows the animation, but at the same time browser will be downloading the content already in the background. On "document ready" event, stop animation.
This will let bots to access the content directly. Because javascript won't work for them.
To make your ajax content crawlable see https://developers.google.com/webmasters/ajax-crawling/, Bing supports this as well. Or use the HTML5 pushState, see http://www.seomoz.org/blog/create-crawlable-link-friendly-ajax-websites-using-pushstate, https://github.com/blog/760-the-tree-slider etc.
I've always thought this is more effort than its worth(generally), but to answer your question:
index.php, aboutme.php, contect.php should deliver full html.
certain links should have js event handlers intercept the click, and instead of loading aboutme.php, they load aboutme-content-only.php in the background. then update the dom and push state etc...
this way the site can easily degrade for those users who are first time visitors, as well as those whose browsers dont support push state or javascript.
I think that it is not a problem at all, keep your href of links as usual, then using JavaScript or jQuery change the default behavior of clicking link to load the linked contents with ajax.

PHP - Open 2 Html Pages

I have this problem to solve.
I gonna make an email campaign to my clients with some affiliate promotions.
The email will have some direct links to the promotions that goes through a php script in my site. (ex: http://mysite.com/promo.php?promoId=x)
In this script I will manage my database queries and cookie.
In cases that I detect through the cookie that this user has not made any click in the last x days I would like to present him with two html pages: my main website page and the external site referring to the promo.
How can I do this? I currently use header( "Location: $promo_url" ) to redirect to the promo url... but in same cases stated before I would need two urls to open.
Thanks in advance for all your answers
GS
You can either use frames (ugh), an iframe within the main page to display the second page (somewhat less ugh), or use popup windows (truly ugh, and probably not possible due to everyone having popup blockers these days).
You could have the script output JavaScript with window.open instead.
<script type="text/javascript">
window.open("link1"); // open link1 in a separate window
window.location.href = "link2"; // point this window to link2
</script>
If you can, however, it would be much better to explicitly show the user a link to the second location somewhere on the page instead of forcefully opening another window / tab for them.
Show them your site, and in your site have a hidden a link tag, which will link to the affiliate site with the attribute _blank. Using jQuery, once the DOM is ready trigger a click event to the hidden link tag.
E.x.
HTML
<a id="affiliateLink" href="http://www.affiliatesite.com/asdad" target="_blank" style="display:none;">Visit Affiliate</a>
JavaScript
$(document).ready(function(){
$('#affiliateLink').trigger('click');
});
There's really no good way to do what you want without using iframes (ugh) or popups (double ugh). The other answers are how to use those techniques, but a possible 'better' solution would be to display a banner on your page when you detect the user hasn't been to your site in a while. The banner could say something along the lines of Click here for information about our awesome promotion, and it'd be easy to make it stand out. That way, you're not forcing popups (which no one will ever see), and while iframes aren't terrible from a user perspective, they don't really scream "modern web design".

Facebook Iframe Issue

I am working on an iframe based Facebook applicaton. I am able to use FB.Canvas.setAutoResize(); to let the iframe "stretch" the page so there's no scroll bar for the iframe. The page may be 2-3 page-length in height. I can scroll down the page using the windows scroll bar. The issue is when I am at the bottom of the page and I click a link inside the frame, the content in the frame loads but I am still at the bottom of the page. Is there a way to set it so that when the link inside the frame is clicked, the outer page will scroll back up to the top of the page so you can see the content of the frame at the top?
Mike
The best solution I've found is to make sure any links below the fold target '_top' and href 'apps.facebook.com/appname/?whatever'. In essense, you're reloading the FB chrome on every click.
This has the added benefit of sending new access_tokens more often.
UPDATE: Facebook announced today that this now works:
FB.Canvas.scrollTo(0,0);

Ads in a PHP based webpage

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?
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.
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
With a setTimeout() in javascript to make a <div> containing the link visible after some amount of time.

Categories