I’m sure this is a simple question but I’m having some trouble finding the answer. I have a website I am designing that has multiple HTML pages. The main page is a standard “index.html” file and the subsequent pages are filed in a folder titled “HTML”. In one of these secondary pages, I want to run my P5.js canvas.
When I was running the sketch on the “index.html” page I was using the .parent() function. In the “index.html” file I have a
<div id = 'sketch-holder'> element to place the canvas on the page.
canvas = createCanvas(650, 375);
That worked fine. Then I decided I wanted to see how the site would function with the JS canvas running on a different HTML page, so I moved that
<div id = 'sketch-holder'> into one of the html files in the “HTML” directory. The canvas is not on the new page and I have a 404 File not found error in the consol.
When I am pointing to an html file in the subdirectory, do I need to put something different in the canvas.parent() function? Something like this:
Thank you all as always for the help.
Thank you for the response!
The beginning of the secondary HTML does include the following.
The sketch.js and Tile.js files both work to create the effect I’m going for on the canvas. I also includd the “…/” because the .js files are in the main directory where as the HTML for the secondary pages is in a HTML/ directory. Do I not need those and maybe that was my issue?
I thought maybe initially that I was just misusing the .parent() function.
Your usage of
libraries folder also a level above the subdirectory where this HTML file is? Perhaps you need to be using