[thelist] Looking for Mr. JavaScript
David Dorward
evolt at david.us-lot.org
Thu Feb 12 09:31:58 CST 2004
On 12 Feb 2004, at 03:18, Sam Carter wrote:
> I need a JavaScript that will emulate the function of the browser's
> back
> button on
"Hi, click here to go back, and would you like me to tie your shoelaces
while I'm at it?"[1]
> <img src="backbutton.gif" onclick="myscript">
>
> with this caveat:
>
> If JavaScript is disabled, I need to *NOT* render the <img>, instead -
> render text that reads "Use your browser's back button to return".
>
> <noscript> should take care of the latter, but I'm not sure how I can
> omit
> rendering of the <img onclick="myscript"> if JS is disabled? After
> all, JS
> will be disabled, so it isn't a tool that can omit rendering.
>
> Any ideas? CSS display:none when JavaScript is disabled? Any way to do
> that?
How do you know CSS is going to be available if JS isn't? The odds are
rather lower then if it is.
Assuming you aren't using XHTML (because XHTML and document.write don't
play nicely together in current browsers), I guess the following will
do the job:
<script type="text/javascript">
document.write("<img src='backbutton.gif' alt='Redundant Back Button'
onclick='history.back(1);'>");
</script>
[1] Yes, its true, I find attempts to duplicate a function built in to
every $%^&ing browser in existence highly annoying.
--
David Dorward
http://dorward.me.uk/
More information about the thelist
mailing list