Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to specify the root of the project to call JS functions from HTML
    primarykey
    data
    text
    <p>In my project i have such structure:</p> <pre><code>/simpleTest /src /demo.js /test /subfolder /index.html </code></pre> <p>What i need is to include my <strong>demo.js</strong> file into my <strong>index.html</strong>, to be able to call js functions from my html.</p> <p>Here is what i have in my html: </p> <pre><code>&lt;head&gt; &lt;title&gt;Test case&lt;/title&gt; &lt;script type="text/javascript" src="/simpleTest/src/demo.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button type="button" onclick="callTest()"&gt;Click&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; &lt;/html&gt; </code></pre> <p>Here is my simple javascript file:</p> <pre><code>function callTest(){ alert("!"); } </code></pre> <p>If i leave it like this - nothing happens, when i press "Click" button. I also have tried to change src path to <em>"../simpleTest/src/demo.js"</em>, <em>"./simpleTest/src/demo.js"</em>, <em>"simpleTest/src/demo.js"</em>, <em>"../src/demo.js", "./src/demo.js"</em>, <em>"src/demo.js"</em>, but it only works with absolute path: <em>"C:\Users\Me\Desktop\simpleTest\src\demo.js"</em> which is not applicable for any real project.</p> <p>Also, if i change src path to <em>"demo.js"</em> and a structure to</p> <pre><code>/simpleTest /demo.js /index.html </code></pre> <p>it works, as well as changing path to <em>"../src/demo.js"</em> and structure to</p> <pre><code>/simpleTest /src /demo.js /test /index.html </code></pre> <p>helps. But both of this desidions are not for me (i have a certain purposes to have a structure, which i've mentioned at the beginning of the post).</p> <p>So, please, tell me how can i specify the root of my project for the structure a want, to fit the src path to the first one structure?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload