Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

21.10.10

Disable Direct Access to iframe !

Hey today i'm gonna show you how to NOT let people access your iframe directly !

It's quiet simple in JavaScript ;)

here is the code: (make sure you put it above the </head> tag)

<script type="text/javascript">
    if (top.location == self.location) {
        top.location = "FULL-URL-HERE";
    }
</script>
Just make sure you replace the "FULL-URL-HERE" to the URL you would like to redirect them ;)

And you'r done no one can access your iframe directly :)

20.9.10

Internet Explorer breaks setInterval ?

Today i faced a stupid bug in Internet Explorer 8 and javascript.

I had my code in javascript: setInterval(timer, 0.1);
If you are not familiar with setInterval <- click the link :)

This code worked perfectly on any browser except IE 8 and below.
I sat for hours trying to sort it out, and finely found the problem.

IE is too slow to make this loop work... (WTF?)
So i changed it to setInterval(timer, 1); And tested it on few computers..

Only fast PCs could run this code on IE.. but on other browsers it worked perfectly even on slow PCs.

SO.... i changed the line to setInterval(timer, 10); and its finely did the job.

This article was written to tell you DO NOT USE IE.

Friends doesn't let friends use Internet Explorer.