www.webdeveloper.com
Results 1 to 8 of 8

Thread: How to block printf

  1. #1
    Join Date
    Feb 2012
    Posts
    33

    How to block printf

    Hello

    I want to translate my site in to ways. Javascript if its available and php if not.
    So i need to block php printf in this example <div>printf</div> when js is available. Becouse i dont need it in case when browser can use js. But i dont know how i can do it.

    Thank you for your replies

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    That's not going to work, there is no way to know server side if JavaScript is available client side. Unless you always assume no JavaScript on the first landing and then use JavaScript to set a cookie that PHP looks for on subsequent requests. And I suppose that you could have a JavaScript reload after that cookie is set. Not very elegant and a wee bit slow. Better to make good use of the NOSCRIPT element and make sure that everything is there on the page somewhere.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,925
    Could you put the printf() output within HTML <noscript> tags?
    "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

    eBookworm.us

  4. #4
    Join Date
    Feb 2012
    Posts
    33
    Quote Originally Posted by NogDog View Post
    Could you put the printf() output within HTML <noscript> tags?
    In php <div><?php printf ?></div>???

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    PHP Code:
    <noscript><div><?php printf ?></div></noscript>
    See http://www.w3.org/TR/html4/interact/...#edef-NOSCRIPT .
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,925
    PHP Code:
    <noscript><div><?php printf("something"); ?></div></noscript>
    Or if you want the <div> tags accessible via the JavaScript:
    PHP Code:
    <div id='foo'><noscript><?php printf("something"); ?></noscript></div>
    "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

    eBookworm.us

  7. #7
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    However, the NOSCRIPT element only directly contains block level elements. If you put the DIV outside the NOSCRIPT then you will need to printf some other block level tags.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  8. #8
    Join Date
    Feb 2012
    Posts
    33
    Thanks a lot

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