Forum Moderators: coopster

Message Too Old, No Replies

conditional SSI for <NOSCRIPT>

any clever work arounds? is this possible?

         

amznVibe

8:13 am on Jan 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This almost seems impossible to me, so of course I'll post it here to see what the gurus can come up with :)

Is it possible to use conditional SSI with the browser <NOSCRIPT> tag to cause a file to display only when there is no javascript available?

Just in case someone is thinking it, this is NOT for cloaking. It is to allow some visitors who have ancient browsers, or chose to browse without javascript, to come into a main index.htm page and see something useful if they pass through <NOFRAMES> and <NOSCRIPT>. Basically I don't want to re-write an entire page of static content with the <NOSCRIPT> section and radically bloat the file size.

The problem lies in that javascript or the lack of it, is based within the browser, and SSI is based within the server. I know of easy tricks to put SSI data into javascript variables, but for the other way around, I am stumped.

I could also use PHP on this server, but I am not knowledgable enough to know if the answer lies within PHP.

This seems to be highly unlikely to achieve, but thanks for any help!

jatar_k

8:55 pm on Jan 31, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I assume that if someone surfs in with no js your site loses functionality?

Are we talking a whole menu system that won't work or just some rollovers?

Just wanting a little more info to better understand the issues involved before I throw in my 2 cents.

andreasfriedrich

11:37 pm on Jan 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible to use conditional SSI with the browser <NOSCRIPT> tag to cause a file to display only when there is no javascript available?

Not on the same page. Since at the time when the browser encounters the noscript element your document is already on the client machine and you have no way of altering it on the server.

You would need to detect that a user does not use javascript and then serve a different version of your document. This could be done using SSI. So it is a two step process that will require two client/server transactions.

Andreas

amznVibe

4:28 am on Feb 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah thanks Andreas, that just lit up some lightbulbs over my head. Didn't think of breaking it into a two step process and I know how to approach that now.

By the way, can PHP work more dynamically with static content? Meaning changes while the page is loading, rather than only 100% before the page loads on the client? Or is it just like SSI where it can only can evaluate or add data from the server before the client begins to download?

andreasfriedrich

8:56 am on Feb 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP is just like SSI in that respect. The kind of client/server transaction you are suggesting is just not possible using HTTP. The client requests a resource. It then sits around waiting for a response from the server. Since HTTP does not keep state between requests there is no way for the client to refer to the request it just send and make the server alter it. Likewise the server has no way of changing anything once it is sent.

However, this does not imply that the whole document needs to be created first and is only then sent to the client. The client might very well receive some data while the server is still working on producing the rest of the resource. There is just no simple way to refer to that server response from the client.

You could achieve something like it if you were to send your data using a content type of multipart/x-mixed-replace. Once you have sent that header you could send a new resource to the client whenever you want from your script. The connection would stay open all the time and the client would replace the content shown once a new document arrives. In one of those earlier documents you could check whether javascript is available and then send a request to the server indicating whether it was available.

Now all you would need is a way for the script that gets called by this request to communicate to the script serving the multipart/x-mixed-replace content that it should send content that does not contain any javascript. The most severe drawback using this approach is that it does not work in IE :(

And even if you were using this approach it would still be a two step process ;). So there is really little to be gained from it. However, it does work quite nicely in controlled environments.

Andreas

amznVibe

11:24 am on Feb 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Andreas you are a true gem around here. Thanks again for your great explanations and insights. -aV-

daisho

9:30 pm on Feb 4, 2003 (gmt 0)

10+ Year Member



You may want to look into using a browscap.ini file (Supported in PHP and ASP)

This is a browser capability file which depending on the browscap you can can contain 1000's of UserAgents and their abilities.

Once installed you can (in php) to $browser=get_browser(); and $broswer will be an object of all the capabilities of the UA.

The one catch with this is that since it is server side you have no way of telling if JS is turned off.

daisho