Where does the snippet or Javascript get processed when we enter that in input box of HTML page or any URL?

Does it go to the server and come back or does the browser process it?


2 Answers 2


Does it go to the server and come back or does the browser process it?

Actually, both. When you enter some data in a form field and send it, the server does something with this data (it typically saves it into a database). If the data contains Javascript code, the server doesn't care, it just saves it as if it was normal text (remember that Javascript is a client-side language, the server cannot execute it).

When you want to view this information that has been saved in the database, the server sends the requested data back to the user. This data is handled by the browser, which will care about rendering the webpage. If the requested data contains Javascript code, this will be executed in this moment.

  • thanks a lot for this info.I got the answer for my question. Does it go to the server and come back or does the browser process it? what i meant was weather the browser process it without sending it to server. i m a newbie sorry if any mistakes..
    – dany
    May 17, 2012 at 12:29
  • @dany you're welcome. Mark the answer as accepted if it answered your question. Javascript code is processed when the webpage is rendered, so when you ask for the information, not when you enter it, meaning that if you enter some malicious code into a form field, you won't see its effects when you insert it, but only when you try to view that information again. May 17, 2012 at 12:44
  • @ user1301428 ..yes i did and thanks a lot for info
    – dany
    May 17, 2012 at 12:49
  • @dany to do it you need to click on the checkmark under the arrows on the left of my answer ;) May 17, 2012 at 12:56

You should first learn, how the browser works... Read this http://taligarsiel.com/Projects/howbrowserswork1.htm

  • Thats a good link. Though I don't know why you'd ask to read all that just to understand how XSS works ! May 16, 2012 at 18:46
  • thanks a lot...pls let me know if there is any other similar site which explains about web server working..
    – dany
    May 17, 2012 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .