SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    <title class="lol"> bronze trophy TehYoyo's Avatar
    Join Date
    Feb 2012
    Location
    Northeast Chicago Suburbs
    Posts
    806
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)

    Using Javascript to hide certain things

    Hey all. For a website that I'm constructing for a school project (lucky me, huh?), I'll be using HTML5 (not best practice, but please don't rip me for it). In order to enable HTML5, I'm running the HTML5 shiv Javascript plug-in hosted by Google. Therefore, I want to display a message saying 'You need to have Javascript enabled for this to work. Accept the message at the top of your screen please.' if Javascript is not enabled, and then have it disappear if it's enabled.

    The way that I want to do it is this:

    I'll make a paragraph of text displaying the message. Upon enabling the Javascript, a separate script that adds a display:none declaration to the paragraph will run. Problem is, I can't do that with my limited abilities.

    Help please.

    Thanks.
    ~TehYoyo

  2. #2
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    5,345
    Mentioned
    214 Post(s)
    Tagged
    5 Thread(s)
    Quote Originally Posted by TehYoyo View Post
    Hey all. For a website that I'm constructing for a school project (lucky me, huh?), I'll be using HTML5 (not best practice, but please don't rip me for it). In order to enable HTML5, I'm running the HTML5 shiv Javascript plug-in hosted by Google. Therefore, I want to display a message saying 'You need to have Javascript enabled for this to work. Accept the message at the top of your screen please.' if Javascript is not enabled, and then have it disappear if it's enabled.
    You might want to rethink that message. There are people who - for whatever reason - might not be able to enable JavaScript, as well as those who choose not to. If I came across a message saying 'You need to have Javascript enabled for this to work', I'd probably just leave the site. Try something a bit more cajoling - like "To see our site at its best, please enable JavaScript". Because it will still be accessible without JavaScript, won't it?

    The easiest way to display something where JavaScript is not enabled would be to use <noscript>. I'm guessing you could use CSS to position the message wherever you choose, but I can't say I've ever done this. I don't use HTML5.
    Don't be arrogant. Be kind to a koala that thinks it's a bear.

  3. #3
    <title class="lol"> bronze trophy TehYoyo's Avatar
    Join Date
    Feb 2012
    Location
    Northeast Chicago Suburbs
    Posts
    806
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Yeah...I'm rethinking my fascination with HTML5...it's probably (actually, it's definitely) not a good idea to use it for every website...

    Thanks.

    ~TehYoyo

    Oh hey! Grats on 1000 posts!

  4. #4
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    5,345
    Mentioned
    214 Post(s)
    Tagged
    5 Thread(s)
    Quote Originally Posted by TehYoyo View Post
    Yeah...I'm rethinking my fascination with HTML5...it's probably (actually, it's definitely) not a good idea to use it for every website...
    I wouldn't argue with that. Better to use something that already works, rather than something that only works with JavaScript now, but might work sometime in the future, provided the specs don't change too much in the meantime.
    Quote Originally Posted by TehYoyo View Post
    Oh hey! Grats on 1000 posts!
    Thank you. I actually reached that number replying to another of your threads. Of course, it isn't quantity that matters but quality - and you can't judge that without reading them all.
    Don't be arrogant. Be kind to a koala that thinks it's a bear.

  5. #5
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    General Discussion posts don't count towards that total number they have zero weight else my actual 'Posts:' count would be far higher, etc.

    Like was said as a general rule you are better off using a normative markup language. Remember your teachers will be marking the work so need to understand it too. As Fred is experimental that would be hard to quantify regarding any useful semantics.

    Typically the more elegant code; is that, which is already richly semantic exists and works, is in the form of HTML 4.01 or XHTML 1.0 and is "fit for purpose" thus wouldn't need JS - just to render - or would work as efficiently without it.


Bookmarks

Posting Permissions

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