1

https://docs.google.com/file/d/0BzVXz9FRg0DWV3R0WUR2cTd5U00/edit

I need to call the function from the javascript linked above in my userscript. My code where I need the function looks like this:

jQuery(document).ready(function($) {
  $('.color1').colorPicker();
});

I tried:

var decolorpicker = '<script type="text/javascript" scr=”www.drive.google.com/file/d/0BzVXz9FRg0DWV3R0WUR2cTd5U00/edit?usp=sharing”></script>'
$("script[src*='merged/game']").after(decolorpicker);

And then:

window.colorPicker(); 

Which gives the error:

Uncaught exception: TypeError: 'window.colorPicker' is not a function

How can I do this correctly?

1 Answer 1

1
<!-- declare your markup first -->
  <div class="color1"></div>

<!-- then include your functions ( jquery also ) -->
<script src="www.drive.google.com/file/d/0BzVXz9FRg0DWV3R0WUR2cTd5U00/edit?usp=sharing"></script>

<!-- then you can apply  -->
<script>
   $('.color1').colorPicker();
</script>

UPDATE:

Make sure that the linked JS is a javascript file. When I visit www.drive.google.com/file/d/0BzVXz9FRg0DWV3R0WUR2cTd5U00/edit?usp=sharing it takes me to a google docs file. This is NOT a javascript file.

Sign up to request clarification or add additional context in comments.

5 Comments

I notice that, when I add the JS file, the link changes to: <script type="text/javascript" scr="�yourjavascript.com/1694801572/colorpickernew.js�"/>. Those two weird icons, why are they there? :x
Just something I copied from your example, they should be simple quotes, what are you editing in ? Just about to make an update -
I'm using Komodo Edit 8.0. And it's not your code I'm using (yet), but when I inspected the head of the page, i noticed I get those two weird symbols added to the src, and when I check resources, the script isn't found. So I think I'm doing something wrong when adding the source javascript
Kk, my bad, I copied those ""'s but they were in a different coding. Thx
yes, looks like the file from the google docs is not downloading as a text only javascript file and is a webpage. Glad you got sorted

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.