Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your code looks really messy though until someone tells you that you're not going to know how to fix stuff.</p> <p>So first thing is first, YOU know what your server-side code should look like so I'm going to concentrate on JUST the client-side code.</p> <p>Don't emulate lazy programmers, you'll end up making more work for yourself than if you put in the extra effort up-front. Stick to the strictest standards compliant code (which generates the least amount of subjectivity). Keep your script elements ONLY as children of the head element, NEVER stick them in the body element. Not only do script elements in the body element encourage really bad coding practices up-front they will severely hamper your ability to achieve your goals in the long term.</p> <p>A note, only IE6 and older do not support application/javascript which is the correct media type/mime for JavaScript files and scripting in general however at this point there is simply no point in supporting IE6 as it's market share is below 1% and most IE6 user agents are spammers and even bots run by Microsoft itself (for who knows what reason).</p> <p>Below is a template of how your XHTML code should appear. In general in a live environment you should limit your script elements to two, one for only the anonymous onload function (which allows you to do more than a single thing for the onload event which is only allowed to exist once for an XHTML application) as well as any global variables if need be (variables defined outside of a function) and the first script element should contain the bulk of your functions. You can use sever-side scripting to combine multiple JavaScript files to be served as a single file for your bulk functions script file.</p> <p>Here is the XHTML template, adapt your JavaScript code and be sure to make use of the JavaScript error consoles in browsers (Engine = browsers: Gecko = Firefox, KHMTL = Konqueror (KDE/Linux), Presto = Opera, Trident = Internet Explorer, WebKit = Chrome/Safari (WebKit is a fork for these two browsers, WebKit itself is a fork from KHTML).</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt; &lt;head&gt; &lt;title&gt;Example XHTML Application&lt;/title&gt; &lt;script type="application/javascript"&gt; //&lt;![CDATA[ a_function() { //stuff } window.onload = function() { //function1(); //function2(); //function3('parameter1','parameter2','parameter3'); alert(window.location.href); } //]]&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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.
    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