Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I write a JavaScript code inside a url?

Here is a URL:

www.google.com

I want to write a JavaScript code inside the URL like :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

alert(), document.write(), console.log() ..etc

If there no way tell me !.

Thanks.

>Solution :

No.

You can’t construct a URL that will execute JavaScript of your devising on an arbitrary web page.

If you could, it would be a major security problem as you could both exfiltrate any data you liked from the page and manipulate the DOM to mislead the people who opened the URL.

Sometimes a website has a server side flaw which causes data from the URL to be injected into the page. This is called an XSS security vulnerability and is an important thing for server-side developers to be aware of so they can avoid it. (It is also possible to create XSS issues using client-side JS, but it is less common).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading