Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>Ideally</em> you would have an option for those with Javascript disabled:</p> <pre><code>&lt;a href="degrade_option.html" onclick="return fancy_option();"&gt;do the option!&lt;/a&gt; </code></pre> <p>If you're not into that sort of thing, although you really should be, the most common way is to use the pound but then cancel the event to prevent the default action from happening, like so:</p> <pre><code>&lt;a href="#" onclick="return do_something();"&gt;do something&lt;/a&gt; </code></pre> <p>But then you have to make sure <code>do_something</code> returns <code>false</code>. (or you can just add <code>return false;</code> at the end of the click handler, but this gets even more unsightly fast)</p> <p>Although, to be honest, you really shouldn't have inline Javascript attributes to begin with. They are bad practice, a nightmare to maintain, and there are much better alternatives out there.</p> <p><strong>EDIT</strong>: In response to your comment, the alternative is <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" rel="noreferrer">unobtrusive javascript</a>:</p> <blockquote> <p>"Unobtrusive JavaScript" is an emerging technique in the JavaScript programming language, as used on the World Wide Web. Though the term is not formally defined, its basic principles are generally understood to include:</p> <ul> <li>Separation of functionality (the "behavior layer") from a Web page's structure/content and presentation</li> <li>Best practices to avoid the problems of traditional JavaScript programming (such as browser inconsistencies and lack of scalability)</li> <li>Progressive enhancement to support user agents that may not support advanced JavaScript functionality</li> </ul> </blockquote> <p>Read the page for some examples.</p>
 

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