Currently Browsing: javascript

Disallow to load your page in iframe

You may use next code to make problems for somebody, who is loading your page in iFrame:

if((self.parent && !(self.parent===self)) && (self.parent.frames.length != 0)){
self.parent.location=document.location;
}

MooTools actions on browser window resize

When you need make some action using MooTools on window resize you should use a timer:

window.addEvent('resize', function(){
    $clear(timer);
    var timer = (function(){
        // your actions goes here
    }).delay(50);
});

You may play with timer delay.

How To Make A Custom Twitter Feed For Your Website

Inserting JavaScript

To get your Twitter feed to pull from your latest tweet from your Twitter account, you are going to need to insert some JavaScript into the page your feed will rest in.  There are several areas where you can place this code but I, and many others, have found that the best place is to place it at the very end of your code, right before the end </body> tag.

<script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
<script src="http://twitter.com/statuses/user_timeline/REPLACE.json?callback=twitterCallback2&count=1" type="text/javascript"></script>

In the code above, swap the word “REPLACE” with your account name. An example would be if your account name was “twitter.com/ChrisKirkman,” you would just place “ChrisKirkman” in there instead of the word “REPLACE.” If you do decide to display multiple tweets, instead of the one that I suggested, then all you will have to do is change where it says “count=1” to whatever number of tweets you would like to display.  Where it links to “blogger.js,” you can have your own file on your server that you link to that has the same information with some minor tweaks, if you like.

Inserting the HTML into your page

<div id="twitter_t"></div>
<div id="twitter_m">
<div id="twitter_container">
<ul id="twitter_update_list"></ul>
</div>
</div>
<div id="twitter_b"></div>

The code above references the CSS that was styled earlier on.  Based off of your layout, all of that code could be thrown into another container (or table) to allow it to work best with the rest of your layout design.

 

 

How to hide/show flash and embed using javascript

Some times I need to hide all flash and embeded objects on page (for example to make them not overlay pop-ups etc.), it can be done using next simple javascript code: (more…)

Show/hide elements on page using javascript

In between your <head> tags put this java script in (you may put it between <body> tags too): (more…)