Monday, August 30, 2010

How to Create a Popup ad (Adsense or what ever)

When visiting some blogs and webpages we have seen some advertisements appear on top of the content. And they will clover some of the useful content till reader clicks on them several times. It appears to be a pain for the users. But good for the people who want to advertise well. You can see how it appears from the demo here.
Now we'll see how to create this kind of advertisement. Here we have used AdSense as the provider.
  • Login to your blog, And open the Design Tab. -> Edit HTML -> Check "Expand Widget Templates"
  • Search for the tag. And we are going to place 
    
    
    • Now save that and get out from the editor.
    • Next goto "Add a Gadget" in "Page Elements"
    • The you need to paste the code below in a HTML/JavaScript Gadget ( Which you normally use to paste your AdSense code.

    Sample Embeded Code For Ads:
    • Fill the part between line 7 and 8 with your AdSense Code
    • Now this is ready to go. Enjoy !
    The original document was created by http://www.blogger-widget.com/2010/07/how-to-create-floating-ads-in-blogspot.html

    Wednesday, August 25, 2010

    Read URL Parameters using JavaScript

    Following is the javascript code for get the parameter "userId" from the url.
    So the website url will be displayed as http:.....................whatever.html?userId=balh007&age=77
    The following function will return "blah007"

    function getUserId(){
    name = 'userId';
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
    return "";
    else
    return results[1];
    }