Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript functions not loading
    primarykey
    data
    text
    <p>I'm trying to run a function at pageload:</p> <pre><code>&lt;script type="text/javascript" src="functions.js"&gt;&lt;/script&gt; &lt;body onload="startUp();"&gt; </code></pre> <p>The problem is startUp() isn't running, nor is anything else that I try to refer to in my JS file. I am certain that the link to the JS file is correct; and even if it weren't, I even tried pasting all of functions.js right into the page header--still nothing. This is the content of functions.js:</p> <pre><code>function startUp() { document.write("running"); //for debugging alert("running"); //for debugging stretchAbdomen(); if (defaultStyle()) { setStyleCookie(1, false); } else { //if mobilestyle setStyleCookie(0, false); if (!window.location.hash) { window.location.hash = "#mobilearea"; } } } function stretchAbdomen() { var bodyheight = getbodyheight(); var abdomen = document.getElementById('abdomen'); if (window.innerHeight &gt; bodyheight) { var currentpaddingstring = window.getComputedStyle(abdomen, null).getPropertyValue('padding-bottom'); var currentpadding = Number(currentpaddingstring.substring(0, currentpaddingstring.length - 2)); //-2 removes "px" from string abdomen.style.paddingBottom = (((window.innerHeight - bodyheight) + currentpadding) + "px"; } } function getbodyheight() { var body = document.body, html = document.documentElement; return Math.min( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); } /*** BELOW HERE SHOULD NOT BE RELEVANT FOR THE QUESTION ***/ window.onresize = resetStyleCookie; function defaultStyle() { if (window.getComputedStyle(document.getElementById('mobilearea')).getPropertyValue('width') == "1px") return true; else return false; } function resetStyleCookie() { document.cookie = "stylecookie=" + "; expires=Thu, 01 Jan 1970 00:00:01 GMT;"; setStyleCookie(defaultStyle() ? 1 : 0, true); //forcereset because otherwise it wasn't working on subpages } function setStyleCookie(number, forcereset) { if (document.cookie.indexOf("stylecookie") == -1 || forcereset) { var now = new Date(); var time = now.getTime(); time += 3600 * 150000; now.setTime(time); document.cookie = "stylecookie=" + number + "; expires=" + now.toGMTString() + "; path=/"; } } </code></pre> <p>I have to assume that there's some compile-time problem in functions.js, but my debugging tools show no errors, nor can I find anything myself. The call to startUp() simply does nothing, even when I don't rely on the onload event to call it. Thanks for any insight!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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