Powered by Cellfex RSS Follow me on Spotify

Archive for the ‘Javascript’ Category

linux implementation on javascript. http://bellard.org/jslinux/
You don’t understant – its not emulator or something like that. its pure linux on JavaScript. Too bad it doesn’t have gcc and network support yet :)

I was thinking about for 10 minutes and i still don’t understand “why” although i see a dozen of useful ways to play it around with.

Good luck, Fabrice Bellard.

6 Jun 2011

Linux on JavaScript

Author: Edgars | Filed under: DailyStuff, Javascript

Sometimes in AJAXized world you would like to dynamically change the HTML page title so it gets bookmarked (or cached by search engine) correctly or at least differently).
After the page has been rendered, the only way to change content is via JavaScript (for those who doesn’t know – “ajax” is just a buzzword for one of the JavaScript’s features and not a mumbojumbo technology).
There are numerous ways to change the dynamic title in proper way by using external snippets, but the very basic is simple – just change the global “document” property called “title”. And this can be done also by placing JavaScript anywhere in page source.

<script type=”text/javascript” language=”JavaScript”>
document.title=’your custom title’;
</script>

I must disclaim that OF COURSE, <script> outside <head> is bad manner and not wrapping around CDATA is even bigger crime. But those who know that probably will not google for this stuff anyway.

18 Oct 2010

Dynamic change of HTML title

Author: Edgars | Filed under: DailyStuff, Javascript, Web Development

How to avoid bots (and not to use caption plugins which suck)… there is a trick that works almost always (well, It uses javascript and they work for me always and i never seen a bot avoiding it). Of course there are users disabling javascript but thats soooo ’90.
Better is to use plain javascript but with jQuery it will be faster [for me to write this]. So install jQuery.

So when creating a block for forms plugin, make it go elsewhere like <form id=”frmGuestbook” action=”http://go/away“>
MAYBE there are still users from ’90ties which use IE5.5 or Netscape Navigator and really have disabled javascript so maybe its a good idea to put a warnign too like <div id=”msgCantWriteGuestbookWithoutJS”>Sorry, you must have javascript to write enabled to write in guestbook</div>

Then, in the html header put this code.
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#msgCantWriteGuestbookWithoutJS').hide();
$('frmGuestbook').attr('action', './put/the/real/link/here');
}
</script>

so what it does – with help of jquery it removes a warning and sets normal action attribute for form. Voila. Spam bot walks in, fills out data and gets redirected to http://go/away. Farewell!

there are other tricks but i will tell a bit later (if you dont figure out yourself). For example CSS and empty field trick – Make a 1×1 pixel  transparent input field and name it “name” so bot will 1000% fill it in. And then when you put the posted data in database, just check for value in “name”. If it is filled in, then it was written by nonhuman (or really small miniperson who sees 1×1 pixel text field as normal text field). So, just ignore the post if “name” is not empty.

Anyway, captions are soooooo 2000….

22 Apr 2010

Avoid spambots and spam in HTML forms.

Author: Edgars | Filed under: HTML, Javascript, jQuery

If you get annoyed by xHTML opening NEW windows on JavaScript’s window.open even if you call it to _SELF:


then know, that some browsers (safari, chrome, IE, but not FF) get distracted by uppercase _SELF. Rename it to _self and it’s gonna be ok. Kinda stupid, but moving no xHTML strict isn’t as easy as it was ment to be.

5 Apr 2010

JavaScript’s window.open target and _SELF

Author: Edgars | Filed under: Javascript, Web Development

We all know how great is to make dynamic HTML lists so you may traverse into selections by taking into account what has been selected before. Superduper way would be to use AJAXized calls to server so it takes care of what should be displayed, but what to do if you have already two rendered HTML combo boxes (aka drop-downs) and just must make a JavaScript logic to take care of showing only those options from list 2 that correspond to the selection in list 1. Internet (google) has some examples using JS arrays which totally doesn’t suite me since i prefer “less code – less hassle” principle. And such arrays doesnt fit me since as i said – i have two generated lists and dont want to generate them as arrays and then build up in JavaScript which in my opinion is just an extra step.
Read the rest of this entry »

29 Mar 2010

Dynamic html lists with jQuery

Author: Edgars | Filed under: CSS, HTML, Javascript, Web Development, jQuery