tags:

views:

31

answers:

1

Hi everyone,

I am trying to understand the code (if this is even the code) which comes from thisnext.com website. Basically it allows any user surfing any website to post recommendations. Im interested to know what does the codes mean.

javascript:(function() {
  var x=document.getElementsByTagName('head').item(0);
  var so=document.createElement('script');
  var h=location.hostname.split('.');
  var a=new Array();for(i=h.length-1;i>=0;i=i-1){a[a.length]=h[i];}var d=a.join('/');
  var s='http://www.thisnext.com/js/bookmarklet/'+d+'/';
  if(typeof so !='object') so=document.standardCreateElement('script');
  so.setAttribute('src',s);so.setAttribute('type','text/javascript');
  x.appendChild(so);
})();

Thank you in advance!

A: 

The script loads some sort of script (probably some sort of JSONP setup) from that site (thisnext.com). It does it by creating a new script element and then building a URL based on the current URL (the URL of the page with the script on it).

I edited the code to get rid of the "%20" characters; those are there because the script is probably set up to be used as a bookmarklet.

The direct answer to your question is "no". That script may load some other code that does what you're looking for, but that script does not do anything of the sort.

Pointy
Thank you all for all your comments! Really appreaciate it. As I guess you would know, I am a noob when it comes to programming. Just that this feature intrigues me so much, I just have to ask.Looks like there is more to meet the eye. Just a question, if there is anyone who used their bookmarklet, who happens to be a javascript programmer, what would be your guess on the complexity of this script? Coz I would love to learn too =)
Shyan Jun