Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  192] [ 7]  / answers: 1 / hits: 43652  / 9 Years ago, sun, april 26, 2015, 12:00:00

How do I take the code from codepen, and use it locally in my text-editor?



http://codepen.io/mfields/pen/BhILt



I am trying to have a play with this creation locally, but when I open it in chrome, I get a blank white page with nothing going on.



<!DOCTYPE HTML>
<html>
<head>
<script> src=https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js></script>
<script type=text/javascript src=celtic.js></script>
<link rel=stylesheet type=text/css src=celtic.css></link>
</head>
<body>
<canvas id=animation width=400 height=400></canvas>
</body>
</html>


I have copy, pasted and saved the css and js into different files and saved them, then tried to link them into the html file as I have shown above.



I have also included the jquery library as I understand a lot of the codepen creations use it.



The only console error I'm getting is



Uncaught TypeError: Cannot read property 'getContext' of null


which is linking to my js file, line 4



(function(){

var canvas = document.getElementById( 'animation' ),
c = canvas.getContext( '2d' ),


Sorry if this is dumb, but I'm new to all this.
I'm sure this is basic as hell. Any help would be awesome!


More From » css

 Answers
11

Joe Fitter is right, but I think is better to export your pen (use the export to export.zip option for using your pen locally). This will give you a working version of your pen without having to copy and paste the CSS, JavaScript and HTML code and without having to make changes on it for making it work.


[#66892] Friday, April 24, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mustafaericho

Total Points: 322
Total Questions: 103
Total Answers: 110

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
mustafaericho questions
Mon, May 31, 21, 00:00, 3 Years ago
Sun, May 23, 21, 00:00, 3 Years ago
Sat, Feb 13, 21, 00:00, 3 Years ago
Sat, Jan 2, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
;