I've found a neat little single drop down for a link list. It works fine, but if I turn JS off in my browser the links will not show. I do have a 100 liner that will show links when JS is off, but I'd rather adapt this to do it.
How do you make it so that the list will show regardless of whether JS is on of off. I want the drop if on, which is why I use it.
Code:
<html>
<head>
<title>Drop div</title>
<style type="text/css">
<!--
#ardd{ width:180px;}
#hide {width:180px; display:none; }
-->
</style>
<script type="text/javascript">
<!-- Begin
// --- how do I show links if JS turned off?
function toggle(id) {
var state = document.getElementById(id).style.display;
if (state == 'block') {document.getElementById(id).style.display = 'none';}
else {document.getElementById(id).style.display = 'block';}
}
// End -->
</script>
</head>
<body>
Trouble is if JS turned off it won't show and I want it to.
<div id="ardd">
<a href="#" onclick="toggle('hide');">Archive</a>
</div>
<div id="hide">
<a href="#" onFocus="if(this.blur)this.blur()">Link</a><br>
<a href="#" onFocus="if(this.blur)this.blur()">Link</a><br>
<a href="#" onFocus="if(this.blur)this.blur()">Link</a><br>
<a href="#" onFocus="if(this.blur)this.blur()">Link</a><br>
</div>
</body>
</html>
Actually when you put the noscript tag in the reply it gave me an idea and I've solved it.
It's actually inside a Perl sub routine on the blog script I'm writing. By putting my Perl foreach loop in a seperate sub I can call it as usual and if JS is off then I wrap the sub call again inside the noscript tag and it works a treat - never thought of that before ... hmmm other possibilities on that idea.
The drop is for my archive list so I can have a single column blog if I want and not end up with a huge list going down the screen unless I need it.
So you've been a real help in a sideways sort of way
Thanks
Here is how it can be done in HTML, for those interested.
Code:
<html>
<head>
<title>Drop div</title>
<style type="text/css">
#ardd {width:180px;}
#hide {width:180px; display:none; }
</style>
<script type="text/javascript">
<!-- Begin
function toggle(id) {
var state = document.getElementById(id).style.display;
if (state == 'block') {document.getElementById(id).style.display = 'none';}
else {document.getElementById(id).style.display = 'block';}
}
// End -->
</script>
</head>
<body>
This is how to do it in HTML
<div id="ardd">
<a href="#" onclick="toggle('hide');">Archive</a>
</div>
<noscript>
<div>
<a href="#">Link</a><br>
<a href="#">Link</a><br>
<a href="#">Link</a><br>
<a href="#">Link</a><br>
</div>
</noscript>
<div id="hide">
<a href="#">Link</a><br>
<a href="#">Link</a><br>
<a href="#">Link</a><br>
<a href="#">Link</a><br>
</div>
</body>
</html>
It would be a good habit, for both of you, to start the document with a Doctype. Without a Doctype, browsers will work in quirks mode, that means unpredictable
dont forget, I believe it's chrome, doesnt support the noscript tag unless it got updated recently
No notify came thru about the replies.
I couldn't even find how to turn JS off in Chrome and assume you can't. Unless it's hidden so deep ......
All the others seem to work fine with it. Since noscript is a standard thing, then Chrome will just have to get their thumb out.
I'm trying very hard to keep the blog package under 150k and have all but finished at 146k, so will probably leave as is. I wanted to be able to post code and not have megabytes of JS WYWISYG to do it and have managed it. So am quite pleased. Perl and a baby JS HTML editor do the stuff.
If anyone's interested in having a go with it, PM me. I've nearly completed it, just have to code the installer.
I've grabbed the latest one JMRKER and will play with that too - thanks.
Bookmarks