Tags?", "text": "<p>I've a JavaScript file that processes tab switches. Here is the source:</p>\n\n<pre class="prettyprint"><code>var tCount = 0;\n\nfunction SwitchToTab(id) {\n if (id < 0 || id > tCount) { id = 0; }\n\n for (var i = 0; i < tCount; i++) { document.getElementById("tab" + i).className = ""; }\n document.getElementById("tab" + id).className = "active";\n\n for (var i = 0; i < tCount; i++) { document.getElementById("area" + i).style.display = "none"; }\n document.getElementById("area" + id).style.display = "";\n}\n\nfunction InitializeTabs(initialTabId, tabsCount) {\n tCount = tabsCount;\n SwitchToTab(initialTabId);\n}\n</code></pre>\n\n<p>I'm trying to make it as short as possible like this:</p>\n\n<pre class="prettyprint"><code><script src="Resources/Tabs.js">InitializeTabs(0, 4);</script>\n</code></pre>\n\n<p>It doesn't works but it works if I separate them like this:</p>\n\n<pre class="prettyprint"><code><script src="Resources/Tabs.js"></script>\n<script>InitializeTabs(0, 4);</script>\n</code></pre>\n\n<p>So, is there any way to run JavaScript inside <code><script src="..."></script></code> tags? What I am missing?</p>", "answerCount": 1, "upvoteCount": 210, "dateCreated": "2015-04-02 13:21:17", "dateModified": "2022-10-02 11:52:49", "author": { "type": "Person", "name": "MFatihMAR" }, "acceptedAnswer": { "@type": "Answer", "text": "<p>No, this is not possible. The html spec dictates that a <code><script></code> tag does one or the other.</p>\n<p><code><script></code>Tag Html Spec, emphasis mine.</p>\n<blockquote>\n<p>The script may be defined within the contents of the SCRIPT element or in an external file. If the src attribute is not set, user agents must interpret the contents of the element as the script. <strong>If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI.</strong></p>\n</blockquote>", "upvoteCount": 110, "url": "https://exchangetuts.com/run-javascript-inside-script-srcscript-tags-1640541004494441#answer-1652926689383519", "dateCreated": "2022-09-30 23:52:49", "dateModified": "2022-10-02 11:52:49", "author": { "type": "Person", "name": "DLeh" } } } }