dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: noscript tag validation issues

  1. #1
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,362

    noscript tag validation issues

    I guessed this probably wouldn't be valid mark-up, but thought I'd give it a try anyway:
    HTML Code:
    <div onclick="do_something();">
    	<h2><noscript><a href="go-here.html"></noscript>Foo Bar<noscript></a></noscript></h2>
    	<p>Blah blah blah, yadda yadda yadda.</p>
    </div>
    In case it's not obvious, I wanted to make the title of the element a link on the off chance JavaScript was not enabled. It actually worked as desired in Firefox, but the W3C validator complained. (It does not like starting an element but not closing it within a <noscript> element.)

    So I was just wondering if there was any "better" way to accomplish this that is valid mark-up without becoming an overly complex markup mash-up.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,968
    Think that this valid.

    HTML Code:
    <script>
    alert("Support for JavaScript");
    </script>
    <noscript>
        <a href="go-here.html">Foo Bar</a>
    </noscript>
    http://www.w3.org/TR/html-markup/noscript.html
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,362
    To accomplish what I was trying to do while still being totally valid mark-up, I'd have to do something ugly like:
    HTML Code:
    <div onclick="do_something();">
    	<h2><script type="text/javascript">
    		document.write('Foo Bar');
    	</script><noscript><a href="go-here.html">Foo Bar</a></noscript></h2>
    	<p>Blah blah blah, yadda yadda yadda.</p>
    </div>
    Just seems needlessly ugly and breaking the D.R.Y. principle of programming.

    PS: And probably isn't great with text-to speech tools?
    Last edited by NogDog; 07-18-2014 at 02:49 PM.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,968
    IDK if the <noscript> tags can live at the foot of the document body or not, have you tried that way so its out the way?
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles