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 get audio input and audio output as one stream?
Publish date: 2022-02-13 | Comments: 2

Tag: Javascript

javascript: Uncaught TypeError: undefined is not a function
Publish date: 2022-03-02 | Comments: 2

Tag: Javascript

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

Tag: Javascript

jquery undefined function
Publish date: 2022-02-28 | Comments: 1

Tag: Javascript

Help: How do I loop simple JSON objects to iterate all keys and values itself?
Publish date: 2022-03-06 | Comments: 1

Tag: Javascript

Vanilla JavaScript Next & prev Navigation
Publish date: 2022-02-22 | Comments: 1

Tag: Javascript