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?
Dave Newton
161k27 gold badges264 silver badges311 bronze badges
asked Feb 8, 2014 at 13:02
user3117628
7862 gold badges15 silver badges36 bronze badges
1 Answer 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.
m90
11.8k16 gold badges69 silver badges120 bronze badges
answered Feb 8, 2014 at 13:08
Rob Sedgwick
5,2364 gold badges22 silver badges36 bronze badges
Sign up to request clarification or add additional context in comments.
5 Comments
user3117628
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
Rob Sedgwick
Just something I copied from your example, they should be simple quotes, what are you editing in ? Just about to make an update -
user3117628
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
user3117628
Kk, my bad, I copied those ""'s but they were in a different coding. Thx
Rob Sedgwick
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
lang-js