 |
|
 |
The simplest way to detect whether scripting is enabled is probably to do this (see sample below). But I'm not sure what you planned to do once you know. Most of us deny entry to the site if the visitor doesn't meet the requirements, but you could also redirect down two different page paths at this point, one for those with scripting, and one for those without if you want to be supportive of both. <HTML> <BODY> <SCRIPT> document.write("Javascript is enabled"); </SCRIPT> <NOSCRIPT> You need to enable JavaScript for your browser </NOSCRIPT> </BODY> </HTML>
|
|
|
|
 |
|
 |
Yes but how does this help in a sever side environment, how from here do you tell the server javascript is enabled or not for this session ?
This example was mainly designed to help in ajax environment where the navigation is JS dependant , knowing what settings users have their browser to can be very usefull especially for those users that don't run javascript on their browsers.
There are other alternatives to the solution (I will update as soon as i have some time) mainly using 1) Ajax or JS Enabled Web services
2) Browserhawk (a product that requires licensing)
Le Roux Viljoen
Web Developer
PCW New Media
South African Branch
www.pcwnewmedia.com
|
|
|
|
 |
|
|
 |
|
 |
I can see what you are trying to do, but you may be better using unobstrusive DOM scripting to accomplish this. e.g.
<script type="text/javascript">
if (document.createElement && document.getElementById) {
// do something...
}
</script>
Google for "unobtrusive javascript" for more info.
|
|
|
|
 |
|
 |
Someone just gave me a comment on the Request.Browser.JavaScript method, before you start with commenting me with that method or giving me a bad vote, help your self to a texbook or just read my article it explains why this boolean doesnt work effectively.
Le Roux Viljoen
Web Developer
PCW New Media
South African Branch
www.pcwnewmedia.com
|
|
|
|
 |
|
 |
Ok, this is nice and simple , but as u may see that whenever user visits ur page for the first time the page will unpredictly reload again. I think this might annoy the users and reduce the efficiency of your appliacation
Instead I think this improvement will help. Specially if you want to apply this to all your pages
1- Make an external page that is responsible for the receiving the requests . it does not need any query string parameters as when ever this page is called the current Session Variable is set.
2- In each client page u will issue call for this page using the XmlHttpRequset . as hidden request ,so that the whole process done seamless .
Good luck
In The Name OF All The Most Merciful
And Bless His Messenger Mohmed The Greatest Human Ever.....
|
|
|
|
 |
|
 |
Hi thanx for the advice, You see I have been working on a site that uses a backend that controls every bit of content you see in the front end, the front end is coded on a single page Default.aspx this makes provision for a non javascript layer(mostly used for Search engine compliance) and a javascript navigation(Which is fully ajax enabled) if you would like to see the site it is in its prototyping stage, you can go to pcw.pcwnewmedia.co.za, and please excuse the slow loading time we are currently prototyping on a very slow server. You can see more or less what the site does. The reaseon why I coded the page like it is is for spiders, a spider will go into the page (obviously without js to speed up the process) and will be able to index the isapi links in the page content and in the noscript tags. where the javascript enabled layer will have the noscript tags but the ajax links are not SEO compliant. Thank you PS. If you can please direct me to a good tutorial on XmlHttpRequest I would greatly appricate it. Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com
|
|
|
|
 |
|
 |
hi Viljoen, thanks for your reply.
I tried your website , and it looks very nice
But I have two notes you may be interested in.
1- When I opened your link on IE7 I was redirected to the same page with query string Jscript=1 I think this is what your article about. But when I ran the same url on Firefox it did not redirect ,I think I enabled the JavaScript on Firefox. You may want to have a look on this.
2- When I navigated through the links I found out that you have only one page that changes its content in Ajax way, this is nice. But Is not that bad for search engines, I mean how can I search for any topic that is contained in the dynamic contents? I think the search engines are not capable of finding your dynamic content . this was main issue when in my late position as Picostation Web Team Leader http://www.picostation.com. Back then –a year ago- when we decided to port the whole website into the Ajax version , we though we may have one page that does everything , but we dropped that to give us more indexing chances by the search engine .
For the XmlHttpRequest , there is a very good example here on Code project, it is the first article about Ajax , it will help you .
Amr El Adaway
Enterprise Application Software Engineer (www.stisalat.com.eg)
Etisalat Misr (Third Mobile Operator in Egypt)
Formally
Advanced Senior Software Engineer at Blue Bridge (www.bluebridge.net)
And before that Web Team Leader and J2ME Team Leader at Picostation (www.picostation.com)
There are some things worth the wait !!!
|
|
|
|
 |
|
 |
Thanx for the reply. Yesterday I became aware of the firefox issue , it is mainly becuse firefox doesnt run the priece of javascript <script language='javascript' type='text/javascript'> window.location = "url"; </script> but I am working a way around this, now on the SEO compliance, the dynamic content does get indexed as the sever side writes to the document before the page gets rendered ( <- I could be wrong but this is how far I understand it) I eliminated the ?PageID=1 querystring and use ISAPI Rewrite like my nav urls will look like /Home_1.html, If you turn off you js on IE 7 close the window and try and go back in agian you will be able to see a complete non javascript version of the site. The one the search engines would obviously use. I have uncluded noscript tags (I am not 100% sure if it gets indexed by google) but most webcrawlers index these noscript tags, also my footer is a dynamic using a random so this can constantly change and increase the index hits on the search engine. Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com
|
|
|
|
 |
|
 |
Try this script to redirect your page on firefox
<script language=javascript type="text/javascript">
load();
function load()
{
self.window.location="http://www.etisalat.com.eg";
}
</script>
Amr El Adaway
Enterprise Application Software Engineer Etisalat Misr (Third Mobile Operator in Egypt)(www.etisalat.com.eg)
There are some things worth the wait !!!
|
|
|
|
 |
|
 |
I tried that on ebefore it still doesnt work, if I can just put something in the javascript that will post to the JScript=1 page without causing a infinite loop: Here is some code but it keeps on looping
if(typeof( window.innerWidth ) == 'number') //firefox browser or Netscape { if(document.URL != 'default.aspx?JScript=1') { window.location.replace('default.aspx?JScript=1'); } } what did I do wrong here? Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com
|
|
|
|
 |
|
|
 |
|
 |
Thanx I have managed to fix that piece of code. My site works in firefox now
Le Roux Viljoen
Web Developer
PCW New Media
South African Branch
www.pcwnewmedia.com
|
|
|
|
 |
|
 |
Great , can u share the experince ?
1- what was the error.
2- and how did ufix.
____________________________
There are things worth the wait !!
Etisalat
www.etisalat.com.eg
|
|
|
|
 |
|
 |
Sorry I am only replying now, have been very busy with a mirroring project
You remembered my code i used on load,
the plan was to detect if the browser was non IE and if so to use the relevant redirect method.
You can remember in my is statement I use :
document.URL != 'default.aspx?JScript=1'
this was wrong because I needed to have my full domain
document.URL != 'http://www.mysite.com/default.aspx?JScript=1'
Well I guess experimenting with regular expressions could also do the trick but this works fine, see the code below
===========================================================================
if(typeof( window.innerWidth ) == 'number') //firefox browser or Netscape
{
if(document.URL != document.URL != 'http://www.mysite.com/default.aspx?JScript=1')
{
window.location.replace('default.aspx?JScript=1');
}
}
===========================================================================
Thanx for all the advice and help
Le Roux Viljoen
Web Developer
PCW New Media
South African Branch
www.pcwnewmedia.com
|
|
|
|
 |
|
 |
All I had to do to make this work in Firefox was to change
(@"<script language='javascript' type='text/jscript'
to
(@"<script language='javascript' type='text/javascript'
nothing else required.
so,
(pardon my vb)
Private Sub CheckJavascriptEnabled()
If Session("JSChecked") Is Nothing Then
Session("JSChecked") = "Checked"
Dim sb As New StringBuilder
With sb
.AppendLine("<script language='javascript' type='text/javascript'>")
.AppendLine(" window.location = """ + Request.Url.ToString + "&as=1"";")
.AppendLine("</script>")
End With
Response.Write(sb.ToString)
End If
'If the javascript Above executed JScript will have a value
If Not Request.QueryString("as") = Nothing Then
Session("NoScript") = True
End If
End Sub
should do the trick.
What is missing is any sensible response to people turning scripting on and off during the session, but how often does that happen?
Thanks a lot for the tip! - I've been trying to use the noscript tags to achieve the same, but no luck there.
Sad this is not incorporated somehow in the ajax.net framework.
Jkey
|
|
|
|
 |
|
 |
PS: Also tested in Opera and Safari. Works for both. Great idea!
Jokva
|
|
|
|
 |
|
 |
I found a new way of detecting javascript a few months ago you can actualy use the ajax engine to set the JSActive Session some of my early work used the way but if you look at www.arubabreeze you'll find that i used ajax to do the setting for me
get yourself the ms ajax toolkit http://ajax.asp.net also third party ajax controls from www.telerik.com will make your development way easier their prometheus suite is awesome
Le Roux Viljoen
Web Developer
PCW New Media
South African Branch
www.pcwnewmedia.com
|
|
|
|
 |