Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Disable text select on blogger

If You want to disable text select inside blogger posts here is the code for that:


<script type="text/javascript">
/***********************************************
* Disable select-text script- &#169; Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
//form tags to omit in NS6+:
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
</script>

Place above code just before ending </body> tag inside Your blogger template :)

Wordpress - adsense inside posts

Here is sample code for Wordpress widget. With this widget You can place random posts + Google adsense code inside single post.

Rule for showing this box is : If img = 600px , after H2 show box ; else do nothing



And code goes like this:

public function sadrzaj_dodaj_widget($content) {
        if(is_single()) {
            global $post;
            if(has_post_thumbnail($post->ID)) {
                $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
                list($slika_sirina, $slika_visina, $slika_tip, $slika_attr) = getimagesize( get_attached_file( $post_thumbnail_id ) );
                if($slika_sirina == 600) {
                    //Filtriranje samo ako je post
                    $html .= preg_replace('/<\/h{1}2>/', '</h2>'.$this->html_widgeta(), $content, 1);
                    return $html;
                }
            }
        }
        return $content;
    }

Blogspot - How to setup Google Analytics account?

To setup Google Analytic account on the blogspot do this

First of all, You must create new analytic account




On the picture above You can see New Account for this blog. After You have enter all data into form, click button Get code. You will be prompted for Google TOS, which You must Agree with.

After that You will get code for Google Analytics.


Select code and copy it to clipboard.
Now, go to blogspot dashboard and edit template. Find opening <body> tag and paste Google Analytics code right after that line of code.


Wait a few seconds, maybe one minute and You will see the result on the live analytic stream