2

I need help with getting links to work. Links can launch things, such as

javascript:x=document.createElement("script");x.src="https://worldlanguages.github.io/animatedThumbnailsBookmarklet/code.js"; void document.getElementsByTagName("head")[0].appendChild(x);

That works and can launch a script. I am trying to make a colorpicker, but I don't understand why it's not working. Below is my code.

javascript:x=document.createElement("script");x.src="//raw.githubusercontent.com/hellolose/Color-Picker/master/.gitignore/.gitignore"; void document.getElementsByTagName("head")[0].appendChild(x);

It can find the code but It won't launch. I don't know which went wrong, the code or the actual launching. If there are answers, could you please post them in the comments, and if this is already answered then I didn't find it. The ones I found all had answers. : ( Thanks!

2 Answers2

2

The value of the src attribute of a <script> element needs to be a URL pointing to a JavaScript program.

The URL you are providing has Content-Type: text/plain; charset=utf-8 in the headers (this is not a JavaScript Content-Type so it will be stopped by security checks in most browsers) and the content of the file starts with <html lang="en"> so it isn't a JavaScript program anyway.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

You could do the same thing with some JS:

<script>
var hyperlink = document.getElementById("YOUR HYPERLINK ID");

hyperlink.addEventListener("click", displayWheel)

function displayWheel(){
\\ Add all your code here
}
</script>

Also make sure that the <a> tag has the value for the href="#"

mr noob
  • 345
  • 2
  • 14