1

I think the problem with me making money with adsense is the way my links are crafted.

Here's an example in code of how I crafted a link on my mobile site for the second image in the image viewer. Assume the image fills the height of the screen minus the height of the anchor tag boxes (which is explained below):

<div ID="imageviewer">
<img src="picture-2.jpg">
</div>
<span ID="Navigation">
<a href="image-1" ID="L">Last</a> <a href="image-2#FB" onclick="shareinnewwindow()" ID="FB">Share</a> <a href="image-3" ID="N">Next</a>
</span>
<!-- adsense code here -->

Then in CSS, I make the anchor tags boxes of normal button size and apply proper background images to each.

Here's where my problem is. Currently if I select the share button, the new window opens and sharing works but the original screen shifts so that the buttons are at the top of the screen with the advertisement moved up.

I then modified the code as follows:

<div ID="imageviewer">
<img src="picture-2.jpg">
</div>
<span ID="Navigation">
<a href="image-1" ID="L">Last</a> <a href="image-2#imageviewer" onclick="shareinnewwindow()" ID="FB">Share</a> <a href="image-3" ID="N">Next</a>
</span>
<!-- adsense code here -->

As soon as I made that modification, my adsense RPM went up a few cents.

This makes me think that by adding the labels to the end of the urls, I'm missing out on income, but if I don't add labels then the same page reloads. For example, if I had code like:

<a onclick="runscript()" href="page">click me</a>

then when that link is clicked, the page is then reloaded while the script is being run. I tried to avoid the loading via code like:

<a onclick="runscript()" href="page#here" ID="here">click me</a>

But adsense doesn't like it probably because of unwanted jumpiness?

So my question is, How can I make adsense happy and at the same time add labels to the end of the URL defined by href so that the page doesn't reload in the background?

P.S. I almost put this in the programming forum but I didn't because it has to do with the operation of my website and I'm looking for more of what is acceptable from adsense's point of view. For example, do I need to make my link reference a tag with a certain ID a certain number of pixels up from the link? etc.

  • Interesting question. I wish I knew. I am curious by what others can offer on this. – closetnoc Apr 12 '15 at 2:45
  • BTW- I like your questions. Keep asking! I would like to see you succeed the best you can. – closetnoc Apr 12 '15 at 2:48
2

To prevent the page from reloading you simply need to return false; from your runscript function:

function runscript(){
    ....
    return false;
}

That will prevent the link from actually triggering the href when the JavaScript handles the action instead. There will be no jumpiness and the page will not reload.

If you can't edit the function itself, you can do so in the HTML onclick instead:

<a onclick="runscript();return false;" href="page">click me</a>
  • I did read that elsewhere too, but I'm also trying the eventlistener to see how that goes. Thanks tho. – Mike Apr 12 '15 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.