user image

Published in : 2022-03-05

Can we add a javascript or jQuery to the URL?


I am wondering to do something meaningful. I am trying to add a script the URL, when user click on the URL, it should run the script and show them some results on their browser screen. 

My purpose is to add some special effects to the browser. Users can bookmark my link with js code, so when they click on bookmark button, it should run code written with javascript.

Any possible solutions will be highly appreciated.


Rakshit Date : 2022-03-06

Best answers


Best answers


Your purpose is not bad, but most of browsers follow privacy policies. If you do whatever you said above, it is an example of Cross Site Scripting (XSS) Attack.


Such XSS attacks are depending on the server's weakness and vulnerabilities to breach to your system and read data from your URL, they can also inject some malfunctioning script or viruses into a page in such a way that browser needs to forcefully execute that javascript or data.

Due to major security concerns, any giants of the browsers will not allow such things by default.


Let me explain a simple scenario about what I explained just now,

If you create a URL with javascript and when users hit that URL you will get some data from their form. 

In real-time, browsers don't allow it. 

What if they allow such a thing?

Browsers would open the door for all kinds of attacks, like stealing passwords of the user will type into login forms, etc. [It might destroy the internet!]


Shilpa Date : 2022-03-06

Understood, your explanation is quite generous.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How to move a div with its content to TinyMEC editor?
Publish date: 2022-02-11 | Comments: 0

Tag: Javascript

Can I read a local json, image or text file from Javascript?
Publish date: 2022-03-03 | Comments: 1

Tag: Javascript

What is the use of package-lock JSON file?
Publish date: 2022-02-11 | Comments: 3

Tag: Javascript

Javascript: Filtering arrays by it properties?
Publish date: 2022-03-05 | Comments: 1

Tag: Javascript

Javascript Add (+) issue
Publish date: 2022-02-26 | Comments: 1

Tag: Javascript

How do I check if an array includes a value in JavaScript?
Publish date: 2022-02-13 | Comments: 2

Tag: Javascript