Click to See Complete Forum and Search --> : <noscript> issues
cusimar9
02-14-2006, 11:08 AM
I have a calendar which I would like to display in a popup window using Javascript when a user clicks on a link. However, if the user has Javascript disabled, I would like the link to just point to the calendar without using Javascript.
I tried writing it using a combination of <script> and <noscript> tags, but the W3C Validation failed quite badly with it.
Any suggestions?
NogDog
02-14-2006, 11:33 AM
Got a link for us? If not, can you show us your mark-up?
Robert Wellock
02-15-2006, 02:14 PM
In Strict doctype the <noscript> element can only contain block-level elements. Anchors are inline-level.
cusimar9
02-15-2006, 03:39 PM
I'm using HTML 4.01 Strict. Sorry the page in question no longer has the code as I removed it
How can I achieve what I want then?
NogDog
02-15-2006, 07:29 PM
You just need to be sure there's a block-level element as the first child element of the <noscript> tag:
<noscript><p><a href="alternate.html">no-script page</a><p></noscript>
cusimar9
02-16-2006, 04:09 AM
Oh is that all!?? Thanks, I'll try that :)
cusimar9
02-16-2006, 04:26 AM
Its still not validating
This is my code:
<script type="text/javascript">
document.write('<a href="javascript:PopupCalendar(<%=PropertyID%>)"><img src="images/calendar.gif" style="display: block" alt="View Availability Calendar"></a>')
</script>
<noscript>
<p class="nomargin"><a href="calendar.asp?ID=<%=PropertyID%>"><img src="images/calendar.gif" style="display: block" alt="View Availability Calendar"></a></p>
</noscript>
And this is the error it throws up:
Error Line 188 column 162: end tag for element "A" which is not open.
... alt="View Availability Calendar"></a>')
NogDog
02-16-2006, 04:48 AM
It's the HTML within the script itself that causes the error. Work-around is escape the "/" in closing tags:
<script type="text/javascript">
document.write('<a href="javascript:PopupCalendar(<%=PropertyID%>)"><img
src="images/calendar.gif" style="display: block" alt="View Availability Calendar"><\/a>')
</script>
See http://www.htmlhelp.com/tools/validator/problems.html#script for more info
bokeh
02-16-2006, 05:26 PM
<a href="calendar.htm" onclick="return !window.open(this.href)">calendar</a>
cusimar9
02-17-2006, 04:22 AM
Genius Bokeh! That's brilliant :)
bokeh
02-17-2006, 04:45 AM
In Strict doctype the <noscript> element can only contain block-level elements. Anchors are inline-level.That's correct, so, if you want to hide an inline element you have to do something along these lines:<div id="containing_element">
<a id="hidden_with_javascript" href="some.url">Link</a>
<script type="text/javascript">
document.getElementById('hidden_with_javascript').style.display='none';
</script>
</div>