Hiding html code on a webpage??

Discussion in 'Software' started by Dande, Aug 20, 2004.

  1. Dande

    Dande Private E-2

    if i want to show someone a code on a webpage, how do i disable the code so it won't post as the code but will actully show the written code? Thanks
     
  2. Kodo

    Kodo SNATCHSQUATCH

    you need to convert it to it's char value.
    in ASP it's
    response.write Server.HTMLENCODE("MyHtmlCodeVariable")
     
  3. TheDoug

    TheDoug MajorGeek

    I think he/she's asking for something a little simpler. You can use the <xmp> tag to prevent the code from being executed and just display it as text instead. Just put the tag before the code you want to display, and close it with </xmp>.
     
  4. Kodo

    Kodo SNATCHSQUATCH

    xmp is an obsolete HTML tag.
     
  5. goldfish

    goldfish Lt. Sushi.DC

    Or, have it echo it out with javascript :

    document.body.innerText = "<h1>blaa</h1>";

    the easiest way to do that would be make a div
    Code:
    <div id="htmlcode"></div>
    
    and then write it into it using javascript
    Code:
    <script>
    document.getElementById("htmlcode").innerText = "<h1>some html code</h1>";
    </script>
     
  6. goldfish

    goldfish Lt. Sushi.DC

    That wouldnt work. Sorry
     
  7. Dande

    Dande Private E-2

    Doug, the <xml> tags worked, thanks a lot, I wasnt aware of that tag, I was thinking of $lt; tags at first, but that one worked. Oh and I am a she btw;-)
     
  8. TheDoug

    TheDoug MajorGeek

    Mozilla doesn't think so. :)
     
  9. Kodo

    Kodo SNATCHSQUATCH

    just to warn you, it's a depricated tag and is being phased out. You're safe for now, but it's unwise to rely on deprecated tags. Think "future proof".
     
  10. Dande

    Dande Private E-2

    thanks, that's good to know, it's also probably why I never heard of it. Is there another tag that will do the samething, without using all the javascripting?
     
  11. goldfish

    goldfish Lt. Sushi.DC

    Bascialy : no. the w3c is trying to make html less of a "do it all" and leave the complicated stuff up to the scripting/stylesheet languages. e.g. there are a few properties which HTMl doesnt support any more, but CSS does.

    The easiest thing to do would be to have it done server side, as Kodo says, with HTMLEncode or whatever.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds