Forum Moderators: coopster
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!
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
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?
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
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