 |
| ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 15th, 2004, 10:31 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
javascript in asp.net
Hi,
i have whole of bunch of javascript code for the asp.net and how do i check if the javascript is enabled on the client machine...
is javascript is not enabled i just want to display a message asking them to enable javascript...
Thank U.
|
|

September 15th, 2004, 12:08 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Something like this....
<span id='jsEn'>
Please enable JavaScript.
</span>
<script type='text/javascript'>
document.getElementById('jsEn').innerHTML='';
</script>
HTH,
-Snib <><
There are only two stupid questions: the one you don't ask, and the one you ask more than once.
|
|

September 15th, 2004, 03:40 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi snib,
but how do i check if the javascript is enabled or not...
if it is disabled..the code u have given is never going to fire..so i can't use any javascript to check if javascript is enabled or disabled...propably i should do from the codebehind...
but i don't know how?
Thank You.
|
|

September 15th, 2004, 08:40 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you can use the ASP.NET Object Request.Browser
example:
Add A <asp:Label id="msg" runat="server" /> on your page
then
public void Page_Load(object sender,EventArgs e)
{
if(!Request.Browser.JavaScript)
{
msg.Text="You must enable the Javascript";
}
}
Study,Progress,Life...
|
|

September 15th, 2004, 09:57 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
pran,
If the code doesn't fire, the text "Please enable JavaScript" will still display.
-Snib <><
There are only two stupid questions: the one you don't ask, and the one you ask more than once.
|
|

September 16th, 2004, 11:41 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
ok cool i will try that....
well it will always show enable javascript but that is not what i want i want it to display only when javascript is disabled...
thanks for trying though
have a good day
|
|

September 16th, 2004, 03:42 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Try this instead:
<noscript>
Enable JavaScript!
</noscript>
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once.
|
|

September 16th, 2004, 04:09 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
yep snib that worked..thanks alot man.
i don't know why Request.Browser.Javascript would still show true inspite of disabling the JavaScript for some reason...
but <noscript> works that's wonderful..
but all i want to do is..if javascript is not enabled i want the browser to pick an other page like javascripterror.html...
and i don't know how to do that ...
and when does Request.Browser.JavaScript actually show false bczit is true even after i disable scripting.
Thanks again snib.
Have a good day
|
|

September 16th, 2004, 07:01 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Hey pran,
Redirecting to another page would look something like this:
<noscript>
<meta http-equiv='refresh' content='0;url=http://yoursite.com/yourdirectory/yourfile.htm'/>
</noscript>
HTH!
-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once :-)
|
|
The Following User Says Thank You to Snib For This Useful Post:
|
|
|

September 17th, 2004, 12:04 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank You snib. that worked and it's wonderful.
Have a good weekend.
|
|
 |