Duplicate of:
What common web exploits should I know about?
This is a security question.
What should I
Javascript in URL will not be executed, on its own. That by no way means its safe or to be trusted.
A URL is another user input not to be trusted, GET or POST (or any other method for that matter) can cause allot of severe vulnerabilities.
A common example was/is the use of the PHP_SELF
, REQUEST_URI
, SCRIPT_NAME
and similar variables. Developers would mistakenly echo them directly to the browser which led to the script being injected into the page and executed.
I would suggest you start to do allot of reading, these are some good places to start:
OWASP
XSS Cheat Sheet
XSS Prevention Cheat Sheet
Also google around for XSS (cross site scripting), XSRF (Cross Site Request Forgery), and SQL Injection. That will get you started, but it is allot of information to absorb so take your time. It will be worth it in the long run.
I believe the right answer is "it depends".
As others have pointed out, if the web application that is processing your request is naively receiving and echoing back the received payload or URL parameters (for GET requests) then it might be subject to code injection.
However, if the web application sanitizes and/or filters payload/parameters, it shouldn't be a problem.
It also depends on the user agent (e.g. browser), a customized user agent might inject code without user notice if it detects any in the request (don't know of any public one, but that is also possible).
Javascript can be executed against the current page just by putting it in the URL address, e.g.
javascript:;alert(window.document.body.innerHTML);
javascript:;alert(window.document.body.childNodes[0].innerHTML);