BleepingComputer.com: Javascript Detection

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Javascript Detection

#1 User is offline   raw 

  • Bleeping Hacker
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,299
  • Joined: 14-April 04
  • Gender:Male
  • Location:Texas

Posted 20 March 2009 - 11:02 PM

Quote

"We have a public site that requires JavaScript be enabled. When it's not, the visitor is redirected to an error page that explains the website's requirements."

How do we determine if Javascript is enabled?
Use Javascript.
function javascriptEnabled(){
	 return true;
}

Great if it returns true...and if not:
function validateSettings(){

  if(!javascriptEnabled()){
	location.href="no_js.htm";
  }

Hope groovicus doesn't fall out of his chair. And yes...this code is on a production server, up and running.
Posted Image
Posted ImageHOSTFix only works on XP,no longer maintained

#2 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,834
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 21 March 2009 - 09:52 AM

If javascript is not enabled then how would this code execute?

#3 User is offline   Andrew 

  • Bleepin' Night Watchman
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 7,422
  • Joined: 05-December 05
  • Gender:Not Telling
  • Location:Right behind you

Posted 21 March 2009 - 11:52 AM

Romeo29 is right. You could always use the <noscript></noscript> tags to display a message, though.
Help us help you. If HelpBot replies, you MUST follow step 1 in its reply so we know you need help.
Posted Image
Boredom Software Stop Highlighting Things

#4 User is offline   raw 

  • Bleeping Hacker
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,299
  • Joined: 14-April 04
  • Gender:Male
  • Location:Texas

Posted 21 March 2009 - 04:37 PM

View PostRomeo29, on Mar 21 2009, 09:52 AM, said:

If javascript is not enabled then how would this code execute?

Exactly... :thumbsup:
Posted Image
Posted ImageHOSTFix only works on XP,no longer maintained

#5 User is offline   Andrew 

  • Bleepin' Night Watchman
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 7,422
  • Joined: 05-December 05
  • Gender:Not Telling
  • Location:Right behind you

Posted 21 March 2009 - 05:21 PM

Okay, I need to start reading the topics more carefully. I actually thought you were asking why it wasn't working, raw!!

Forgive me, for I know not what I type.
Help us help you. If HelpBot replies, you MUST follow step 1 in its reply so we know you need help.
Posted Image
Boredom Software Stop Highlighting Things

#6 User is offline   Andrew 

  • Bleepin' Night Watchman
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 7,422
  • Joined: 05-December 05
  • Gender:Not Telling
  • Location:Right behind you

Posted 02 April 2009 - 04:50 PM

Wait a cotton pickin' minute! I call shenanigans!! http://thedailywtf.com/Articles/Bulletproo...-Detection.aspx
Help us help you. If HelpBot replies, you MUST follow step 1 in its reply so we know you need help.
Posted Image
Boredom Software Stop Highlighting Things

#7 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,834
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 02 April 2009 - 09:47 PM

One workaround is using JavaScript + PHP and make JS function return to a PHP function. Is this possible? I faintly remember reading this in a book. But I am wrong all time :thumbsup:

#8 User is offline   raw 

  • Bleeping Hacker
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,299
  • Joined: 14-April 04
  • Gender:Male
  • Location:Texas

Posted 03 April 2009 - 09:26 PM

View PostAmazing Andrew, on Apr 2 2009, 04:50 PM, said:

Wait a cotton pickin' minute! I call shenanigans!!

I didn't claim it as my code or my server. Just sharing it. :thumbsup:
Posted Image
Posted ImageHOSTFix only works on XP,no longer maintained

#9 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 04 April 2009 - 01:49 AM

It doesn't work. Test it yourself. Thanks for screwing with my brain for awhile though. :thumbsup:
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#10 User is offline   burn1337 

  • Forum Regular
  • Find Topics
  • Group: Banned
  • Posts: 311
  • Joined: 07-March 09
  • Gender:Male

Posted 04 April 2009 - 05:17 PM

...I have actually be thinking about ways to automatically testing for Javascript... Personally the script that raw showed us, I would not have used at all... Though I am thinking about finding a good way before the headers are processed to test for javascript... I have a couple theoretical ways sitting in my head... But not sure if they will actually work lol...

#11 User is offline   raw 

  • Bleeping Hacker
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,299
  • Joined: 14-April 04
  • Gender:Male
  • Location:Texas

Posted 05 April 2009 - 09:38 PM

View Postburn1337, on Apr 4 2009, 05:17 PM, said:

Personally the script that raw showed us, I would not have used at all...

That was the point. An example of poor coding.
Found this, might be useful.
http://www.missiondata.com/blog/javascript...ript-detection/
Posted Image
Posted ImageHOSTFix only works on XP,no longer maintained

#12 User is offline   burn1337 

  • Forum Regular
  • Find Topics
  • Group: Banned
  • Posts: 311
  • Joined: 07-March 09
  • Gender:Male

Posted 08 April 2009 - 06:58 AM

hhmm... That would work for some... But as for what I am looking for, no way... I have been thinking about using a script/noscript, to set a php variable, then upon that variable will set a session variable so that the switch between straight code, and action scripts would be a bit easier, or the script/noscript variable will be the switch... Not sure how it will go out though... Almost sure it won't work lol... Though I do tend to wonder what ways I could test for it, without needing a redirection, or an ajax test...

This post has been edited by burn1337: 08 April 2009 - 06:59 AM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users