![]() |
Rendering noscript content only
Hi,
This is probably a rather basic question. Anyway, I'm making a site that relies on JavaScript; however, if JavaScript is not enabled I want to show some information instead of the regular content. What is the recommended way to achieve this? For example if JavaScript is not enabled the HTML below will output This site requires a JavaScript enabled browser. This is the regular content. but I want only the first paragraph to be rendered in this case. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Test</title> <script type="text/javascript"></script> </head> <body> <noscript> <p>This site requires a JavaScript enabled browser.</p> </noscript> <p>This is the regular content.</p> </body> </html> August |
Re: Rendering noscript content only
August Karlstrom wrote:
> Anyway, I'm making a site > that relies on JavaScript; however, if JavaScript is not enabled I > want to show some information instead of the regular content. Do you think there is some useful information to be given? > For example if JavaScript is not enabled the HTML below will output > > This site requires a JavaScript enabled browser. Do you think that's useful information? To whom, and why? If I have turned off JavaScript for security reason, should that make me turn it on now? What if company policy has turned it off? Well, I might visit the site on my home computer later. Would I do that just because the site says it requires a JavaScript enabled browser? > This is the regular content. > > but I want only the first paragraph to be rendered in this case. Then you should make the "regular content" JavaScript-generated. The old way is to use document.write(), but especially if you are using XHTML, for some odd or even reason, you should instead manipulate the document tree using "standard" DOM tools. -- Yucca, http://www.cs.tut.fi/~jkorpela/ |
Re: Rendering noscript content only
On Sat, 18 Oct 2008 16:08:56 +0300, "Jukka K. Korpela"
<jkorpela@cs.tut.fi> wrote: >August Karlstrom wrote: > >> Anyway, I'm making a site >> that relies on JavaScript; however, if JavaScript is not enabled I >> want to show some information instead of the regular content. > >Do you think there is some useful information to be given? > >> For example if JavaScript is not enabled the HTML below will output >> >> This site requires a JavaScript enabled browser. > >Do you think that's useful information? To whom, and why? If I have turned >off JavaScript for security reason, should that make me turn it on now? What >if company policy has turned it off? Well, I might visit the site on my home >computer later. Would I do that just because the site says it requires a >JavaScript enabled browser? > >> This is the regular content. >> >> but I want only the first paragraph to be rendered in this case. > >Then you should make the "regular content" JavaScript-generated. The old way >is to use document.write(), but especially if you are using XHTML, for some >odd or even reason, you should instead manipulate the document tree using >"standard" DOM tools. So I have script off, how ya gonna write anything to my page? |
Re: Rendering noscript content only
On Sat, 18 Oct 2008 12:15:32 +0200, August Karlstrom
<fusionfile@gmail.com> wrote: >Hi, > >This is probably a rather basic question. Anyway, I'm making a site that >relies on JavaScript; however, if JavaScript is not enabled I want to >show some information instead of the regular content. What is the >recommended way to achieve this? > >For example if JavaScript is not enabled the HTML below will output > > This site requires a JavaScript enabled browser. > > This is the regular content. > >but I want only the first paragraph to be rendered in this case. > ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> > <head> > <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> > <title>Test</title> > <script type="text/javascript"></script> > </head> > > <body> > <noscript> > <p>This site requires a JavaScript enabled browser.</p> > </noscript> > > <p>This is the regular content.</p> > </body> ></html> > > >August You can direct those with script off to a more friendly page. such as <noscript> direct to page 2</noscript> Or Have a text link to the noscript page. But with more modern browsers, you get told fairly easily if the page isn't kosher scripting and trying to install something like a virus or malware. Statistics show that 10% or less turn off script. I would venture a guess and say that a vast majority don't even know how to turn it off. |
Re: Rendering noscript content only
richard wrote:
> On Sat, 18 Oct 2008 16:08:56 +0300, "Jukka K. Korpela" > <jkorpela@cs.tut.fi> wrote: > >> August Karlstrom wrote: >> >>> Anyway, I'm making a site >>> that relies on JavaScript; however, if JavaScript is not enabled I >>> want to show some information instead of the regular content. >> Do you think there is some useful information to be given? >> >>> For example if JavaScript is not enabled the HTML below will output >>> >>> This site requires a JavaScript enabled browser. >> Do you think that's useful information? To whom, and why? If I have turned >> off JavaScript for security reason, should that make me turn it on now? What >> if company policy has turned it off? Well, I might visit the site on my home >> computer later. Would I do that just because the site says it requires a >> JavaScript enabled browser? >> >>> This is the regular content. >>> >>> but I want only the first paragraph to be rendered in this case. >> Then you should make the "regular content" JavaScript-generated. The old way >> is to use document.write(), but especially if you are using XHTML, for some >> odd or even reason, you should instead manipulate the document tree using >> "standard" DOM tools. > > So I have script off, how ya gonna write anything to my page? You won't, you will only get what is in the NOSCRIPT element which is what the OP wanted...reread. -- Take care, Jonathan ------------------- LITTLE WORKS STUDIO http://www.LittleWorksStudio.com |
Re: Rendering noscript content only
richard wrote:
> On Sat, 18 Oct 2008 12:15:32 +0200, August Karlstrom > <fusionfile@gmail.com> wrote: > >> Hi, >> >> This is probably a rather basic question. Anyway, I'm making a site that >> relies on JavaScript; however, if JavaScript is not enabled I want to >> show some information instead of the regular content. What is the >> recommended way to achieve this? >> >> For example if JavaScript is not enabled the HTML below will output >> >> This site requires a JavaScript enabled browser. >> >> This is the regular content. >> >> but I want only the first paragraph to be rendered in this case. >> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> >> <head> >> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> >> <title>Test</title> >> <script type="text/javascript"></script> >> </head> >> >> <body> >> <noscript> >> <p>This site requires a JavaScript enabled browser.</p> >> </noscript> >> >> <p>This is the regular content.</p> >> </body> >> </html> >> >> >> August > > You can direct those with script off to a more friendly page. > such as <noscript> direct to page 2</noscript> And how do you propose to do the redirect within the noscript element? JavaScript? ;-) -- Take care, Jonathan ------------------- LITTLE WORKS STUDIO http://www.LittleWorksStudio.com |
Re: Rendering noscript content only
On 2008-10-18, Jonathan N. Little wrote:
> richard wrote: >> On Sat, 18 Oct 2008 12:15:32 +0200, August Karlstrom >> <fusionfile@gmail.com> wrote: >> >>> Hi, >>> >>> This is probably a rather basic question. Anyway, I'm making a site that >>> relies on JavaScript; however, if JavaScript is not enabled I want to >>> show some information instead of the regular content. What is the >>> recommended way to achieve this? >>> >>> For example if JavaScript is not enabled the HTML below will output >>> >>> This site requires a JavaScript enabled browser. >>> >>> This is the regular content. >>> >>> but I want only the first paragraph to be rendered in this case. >>> >>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >>> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> >>> <head> >>> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> >>> <title>Test</title> >>> <script type="text/javascript"></script> >>> </head> >>> >>> <body> >>> <noscript> >>> <p>This site requires a JavaScript enabled browser.</p> >>> </noscript> >>> >>> <p>This is the regular content.</p> >>> </body> >>> </html> >>> >>> >>> August >> >> You can direct those with script off to a more friendly page. >> such as <noscript> direct to page 2</noscript> > > And how do you propose to do the redirect within the noscript element? > JavaScript? ;-) He didn't say "redirect", he said "direct", e.g., put a link. -- Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com> ================================================== ================= Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) |
Re: Rendering noscript content only
August Karlstrom wrote:
> Hi, > > This is probably a rather basic question. Anyway, I'm making a site that > relies on JavaScript; however, if JavaScript is not enabled I want to > show some information instead of the regular content. What is the > recommended way to achieve this? > > <snip> The most efficient way to do this is to turn the problem around. Make the page the NON-JavaScript page and use JavaScript to redirect to the JavaScript-Required page. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta http-equiv="content-language" content="en-us"> <title>JavaScript Warning</title> <script type="text/javascript"> //redirection will only happen if JavaScript is enabled window.location.href="JS_REQ_PAGE.html"; </script> </head> <body> <p>Message warning that JavaScript is required to use your site.</p> </body> </html> -- Take care, Jonathan ------------------- LITTLE WORKS STUDIO http://www.LittleWorksStudio.com |
Re: Rendering noscript content only
Chris F.A. Johnson wrote:
>>>> <p>This site requires a JavaScript enabled browser.</p> >>>> </noscript> >>>> >>>> <p>This is the regular content.</p> >>>> </body> >>>> </html> >>>> >>>> >>>> August >>> >>> You can direct those with script off to a more friendly page. >>> such as <noscript> direct to page 2</noscript> >> >> And how do you propose to do the redirect within the noscript >> element? JavaScript? ;-) > > He didn't say "redirect", he said "direct", e.g., put a link. That's absurd. Saying "This site requires a JavaScript enabled browser." is bad, and using a link to a useable page is somewhat better, but why on %Planet; would you tell the user go somewhere to get the content when you can put that content in the <noscript> element? Alternatively, you could write the more friendly content as normal content of the page and use JavaScript redirect, such as <script type="text/javascript"> document.location.href = 'foobar.html'; </script> e.g. at the very start of the <head> element content, to send JavaScript-enabled browsers directly to the JavaScript-dependent page foobar.html. Of course the normal sensible approach is to write the normal content first, then add JavaScript functionality to it in a manner that does not break the page content when JavaScript is off. Then you don't need any of the above. -- Yucca, http://www.cs.tut.fi/~jkorpela/ |
Re: Rendering noscript content only
On Sat, 18 Oct 2008 21:18:32 +0300, "Jukka K. Korpela"
<jkorpela@cs.tut.fi> wrote: >Chris F.A. Johnson wrote: > >>>>> <p>This site requires a JavaScript enabled browser.</p> >>>>> </noscript> >>>>> >>>>> <p>This is the regular content.</p> >>>>> </body> >>>>> </html> >>>>> >>>>> >>>>> August >>>> >>>> You can direct those with script off to a more friendly page. >>>> such as <noscript> direct to page 2</noscript> >>> >>> And how do you propose to do the redirect within the noscript >>> element? JavaScript? ;-) >> >> He didn't say "redirect", he said "direct", e.g., put a link. > >That's absurd. Saying "This site requires a JavaScript enabled browser." is >bad, and using a link to a useable page is somewhat better, but why on >%Planet; would you tell the user go somewhere to get the content when you >can put that content in the <noscript> element? > >Alternatively, you could write the more friendly content as normal content >of the page and use JavaScript redirect, such as ><script type="text/javascript"> >document.location.href = 'foobar.html'; ></script> >e.g. at the very start of the <head> element content, to send >JavaScript-enabled browsers directly to the JavaScript-dependent page >foobar.html. > >Of course the normal sensible approach is to write the normal content first, >then add JavaScript functionality to it in a manner that does not break the >page content when JavaScript is off. Then you don't need any of the above. Which is why I try to make my pages useable without scripting. Witout script, you just get a longer presentation. A page I'm working on now uses script only to make presentation better. It will work just fine without script. |
| All times are GMT. The time now is 12:47 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.