Page 1 of 1

Any possible way to use js code on js Disabled browser

Posted: Mon Mar 10, 2008 6:43 am
by vinoth
HI All..
I am using most of the designing stuff on my site using Javascript, But the user disabled the Javascript on browser,
The designing Js stuff was not working...

I don't know is it possible or not? to make use the JS code on JS diabled Browser.

Anybody suggest or providing ideas to make use the javascript code on javascript disabled Browsers.


Thanks in advance.

Vinoth..

Re: Any possible way to use js code on js Disabled browser

Posted: Mon Mar 10, 2008 7:46 am
by kryles
wouldn't that kind of defeat the purpose of disabling JS?

Just send them to different pages coded in just PHP, or tell them to enable JS to make your site work properly.

Maybe there is a work around that'll work for you, but still.........

Re: Any possible way to use js code on js Disabled browser

Posted: Mon Mar 10, 2008 10:15 am
by Sekka
You need to read into Unobtrusive programming when it comes to JavaScript.

To save you some aggro, here are two options you could implement.

JS Redirect

Create a page. This page has a notice on it saying something along the lines of 'You need to enable JavaScript to use MyTool'. On this page you will add a JavaScript redirect to the actual tool page. If they have JS enabled, they will be redirected to the tool, if not, they will stay on the warning.

Unobtrusive

When your tool page first loads, it needs to assume the user doesn't have JS enabled. So, by default, the page won't have any JS functionality. This could mean the tool is within a hidden DIV and instead a notice is displayed like in the previous example.

What you then do is attach all the functionality to the page using JavaScript itself. For example, you may have a button on your page with an onclick="someFunction()". You wouldn't embed this within the HTML. Instead, you would add the onclick to the button using JavaScript itself.

Once you'd setup all your functionality, you'd then hide the notice and unhide the tool.

This is a very basic overview of Unobtrusive, but do you get what I am trying to tell you?

Re: Any possible way to use js code on js Disabled browser

Posted: Mon Mar 10, 2008 10:15 am
by Sekka
And FYI, this is a JavaScript/HTML question, not PHP.

Re: Any possible way to use js code on js Disabled browser

Posted: Mon Mar 17, 2008 11:10 am
by Jonah Bron
If javascript is disabled, the only thing you can do, is tell them to enable it:

Code: Select all

alert("Sorry, you must enable javascript to view this page");
:rofl:

Re: Any possible way to use js code on js Disabled browser

Posted: Mon Mar 17, 2008 11:16 am
by Zoxive
PHPyoungster wrote:If javascript is disabled, the only thing you can do, is tell them to enable it:

Code: Select all

alert("Sorry, you must enable javascript to view this page");
:rofl:
Hard to tell if you were serious or the "rofl" smiley was to give it away but.. Its kind of pointless trying to alert when javascript is disabled. :mrgreen:

Code: Select all

<noscript>
Sorry, you must enable javascript to view this page.
<noscript>

Re: Any possible way to use js code on js Disabled browser

Posted: Mon Mar 17, 2008 5:06 pm
by Jonah Bron
Glad someone gets it. :lol: