Because I am constantly busy working on something, I have never had time to actually put everything in words and pictures. But, since you got here, then you must have already seen some part of my work - and this is the way I’m talking. I'm 24, born in Romania, studied at UPG Romania in software development field. I started from 0, mostly with basic stuff, and I’m evolving every day to an expert. I'm focused on freelancing projects, from small websites, to really heavy stuff.

Saturday, May 5, 2012

How to kill a Windows process from the command line with taskkill


         If we have a certain process running on a certain port type, on Windows machines we can force shutdown a process folowing a few steps:

              1.   First, run Command Prompt and write:  netstat –a –o –n
                   2. Then, locate the process and port type you want to shutdown and remember his PID, which is a unique identifier of the process.

            
               For this test, we choose to shutdown Tomcat 6.0 that runs on port 8080.

              3.And the final step, write:  taskkill /F /PID 2052

In this case, 2052 is the unique identifier of the process. We will see a short message like:


           That’s it! Quite simple.

Friday, May 4, 2012

Accessing the <span> tag content from JavaScript


Hi again ! For a recent project, I had to use the power of Javascript to obtain the <span> tag content. The first thing that came to my mind was by using the Javascript innerText property, but this was a bad idea. It seems that IE, Crome and Opera supports the innerText property but Firefox doesn’t. Apparently the proper DOM property to use for Firefox is textContent. The textContent property does the same thing as innerText property, at least as a result.
All said, I’ve obtained this code:

function getInnerText(){
   if (document.getElementById("x").innerText) {
      alert("For IE, Crome and Opera: " + document.getElementById("x").innerText);
   } else {
      if (document.getElementById("x").textContent) {
         alert("For Mozilla Firefox: " + document.getElementById("x").textContent);
      } else {
        alert("Error: This application does not support your browser."
                                         + " Try again using IE or Firefox.");     
      }
   }
}

And the HTML is:  

<span id="x" onclick="getInnerText();">Click me!</span>

Then, a second idea had come to my mind. An idea that works in all major browsers without using the if clause. This idea is based on the innerHTML property:

function getInnerText () {
      alert("For all browsers: " + document.getElementById("x").innerHTML);
}

That’s all. Hope it helps!