Click to See Complete Forum and Search --> : wondering if it can be done


Tasmanian Devil
07-10-2003, 04:14 PM
I know this might not be the right place to ask this, but can you use any other methood to make a javascript type of alert box popup. For example, I want a alert box to popup if someone does not have cookies or javascrit enabled, but without the use of javascript.

Thanks

Jona
07-10-2003, 04:18 PM
LOL! No, I don't think it's possible to use JavaScript when it's not enabled. :p

[J]ona

Tasmanian Devil
07-10-2003, 04:24 PM
I was wondering if there is any other methood to check to see if javascript was enabled

Thanks

Jona
07-10-2003, 04:26 PM
It is possible to test whether or not JavaScript is enabled--in fact, I've already done this, however, it requires a server-side language (I used PHP).

[J]ona

Charles
07-10-2003, 04:27 PM
It's the NOSCRIPT element and when used with other methods you can easily make a page that works as well with as without JavaScript.

Tasmanian Devil
07-10-2003, 04:30 PM
Jona~
Would you be able to help me out?

Jona
07-10-2003, 04:31 PM
Originally posted by Tasmanian Devil
Jona~
Would you be able to help me out?

I don't know. Do you have a PHP-enabled server?

[J]ona

kdcgrohl
07-10-2003, 04:37 PM
try this... (http://www.kdcgrohl.com/testing/test_scriptnoscript.html) ;)

Tasmanian Devil
07-10-2003, 06:08 PM
Jona~
Yes I do

Jona
07-10-2003, 07:03 PM
Here's the PHP file that I made. It does misuse meta tags, so you may want to also include a link when it prints out the meta tag, as well. Just in case.


<?PHP if($_GET['jsEnabled']=="yes"){$hasJS="Yes, you do.";}
else {$hasJS = "No, you do not."; $metaTag = "<meta http-equiv=\"refresh\" content=\"0; url=http://sonoracabinets.com/testing/home.php?js=0\">";
} ?>
<html>
<head>
<title>Do you have JavaScript enabled?</title>
<?PHP echo $metaTag; ?>
<script type="text/javascript">
<!--
<?PHP
if($_GET["jsEnabled"]!="yes"){
echo ('location.href="jsEnabled.php?jsEnabled=yes"');
} else {
echo "location.href='http://sonoracabinets.com/testing/home.php?js=1'";
} ?>
//-->
</script>
</head>
<body>
<p style="font-size:24px;">Do you have JavaScript enabled?</p>
<p style="font-size:24px;"><?PHP echo $hasJS ?></p>
</body>
</html>


And here's the home.php file:


<?PHP
$js = $_GET["js"];
if($js==0){
setcookie("js", 0, time()+60*60*24*30, '/', '.sonoracabinets.com');

echo ("<html><head><title>Here is the site with JavaScript disabled.</title></head><body><p align=\"justify\">Since you have JavaScript disabled, this site will be completely compatible for you and your specific needs, including but not limited to, audio and braille browser compatibility. Have fun!</p></body></html>");

} else if($js==1) {
setcookie("js", 1, time()+60*60*24*30, '/', '.sonoracabinets.com');

echo ("<html><head><title>Here is the site with JavaScript enabled.</title></head><body><p align=\"justify\">Since you have JavaScript enabled, this site will be completely enhanced with powerful JavaScript applications and etcetera visual eye-candy. I hope you enjoy it!</p></body></html>");

} else {
echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");
}
//print_r($_COOKIE); print array
//print $_COOKIE["js"]; print cookie value
?>


[J]ona

metrosoccer12
07-10-2003, 07:08 PM
well i dont know how to do it but i guess it could be done, you write in regular font like "You dont have javascript enabled" then using a javascript code u somehow get it to take away the text. That way if they have javascript enabled it wont show the message and if they dont the message will be shown

Jona
07-10-2003, 07:12 PM
Originally posted by metrosoccer12
well i dont know how to do it but i guess it could be done, you write in regular font like "You dont have javascript enabled" then using a javascript code u somehow get it to take away the text. That way if they have javascript enabled it wont show the message and if they dont the message will be shown

Yes, that could be done completely client side, as the below code demonstrates, however, you will not be able to retreive the information unless the form is submitted.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
<!--
onload = function(){document.jsForm.tBox.value="You have JavaScript enabled";}
//-->
</script>
</head>
<body>
<form action="" name="jsForm" method="POST"><div>
<input type="text" name="tBox" value="You do not have JavaScript enabled">
</div></form>
</body></html>


[J]ona

Tasmanian Devil
07-11-2003, 08:23 AM
Jona~
Is this correct?

<?PHP if($_GET['jsEnabled']=="yes"){$hasJS="Yes, you do.";}

else {$hasJS = "No, you do not."; $metaTag = "<meta http-equiv=\"refresh\" content=\"0; url=http://sonoracabinets.com/testing/home.php?js=0\">";

} ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Do you have JavaScript enabled?</title>

<?PHP echo $metaTag; ?>

<script type="text/javascript">

<?PHP

if($_GET["jsEnabled"]!="yes"){

echo ('location.href="jsEnabled.php?jsEnabled=yes"');

} else {

echo "location.href='http://sonoracabinets.com/testing/home.php?js=1'";

} ?>

</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p style="font-size:24px;">Do you have JavaScript enabled?</p>

<p style="font-size:24px;"><?PHP echo $hasJS ?></p>

</body>
</html>

Thanks

Tasmanian Devil
07-11-2003, 10:59 AM
Jona~
Can you check this out and help me out?

http://216.104.190.167/home.php

Not sure if that is what it is to do.

Thanks

Jona
07-11-2003, 12:22 PM
The code I posted works fine. The error you are getting is, "headers already sent," which means you are using the header() function somewhere in your code, after the other headers were sent. You must only use header() at the top of the document before HTML processing begins.

[J]ona

Tasmanian Devil
07-11-2003, 12:33 PM
Jona~
Here is the code I am using, what did I do wrong?

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<?PHP

$js = $_GET["js"];

if($js==0){

setcookie("js", 0, time()+60*60*24*30, '/', '.sonoracabinets.com');

echo ("<html><head><title>Here is the site with JavaScript disabled.</title></head><body><p align=\"justify\">Since you have JavaScript disabled, this site will be completely compatible for you and your specific needs, including but not limited to, audio and braille browser compatibility. Have fun!</p></body></html>");

} else if($js==1) {

setcookie("js", 1, time()+60*60*24*30, '/', '.sonoracabinets.com');

echo ("<html><head><title>Here is the site with JavaScript enabled.</title></head><body><p align=\"justify\">Since you have JavaScript enabled, this site will be completely enhanced with powerful JavaScript applications and etcetera visual eye-candy. I hope you enjoy it!</p></body></html>");

} else {

echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");

}

//print_r($_COOKIE); print array

//print $_COOKIE["js"]; print cookie value

?>

</body>
</html>

Thanks

Jona
07-11-2003, 12:43 PM
The ".sonoracabinets.com" needs to be ".yoursite.com" (And make sure you keep the first dot on there.)

[J]ona

Tasmanian Devil
07-11-2003, 12:50 PM
Jona~
I belive I fixed what you told me to fix, but sill the same error messages. Code is as follows:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#FFFFFF" text="#000000">
<?PHP

$js = $_GET["js"];

if($js==0){

setcookie("js", 0, time()+60*60*24*30, '/', '.foxvalleynews.com');

echo ("<html><head><title>Here is the site with JavaScript disabled.</title></head><body><p align=\"justify\">Since you have JavaScript disabled, this site will be completely compatible for you and your specific needs, including but not limited to, audio and braille browser compatibility. Have fun!</p></body></html>");

} else if($js==1) {

setcookie("js", 1, time()+60*60*24*30, '/', '.foxvalleynews.com');

echo ("<html><head><title>Here is the site with JavaScript enabled.</title></head><body><p align=\"justify\">Since you have JavaScript enabled, this site will be completely enhanced with powerful JavaScript applications and etcetera visual eye-candy. I hope you enjoy it!</p></body></html>");

} else {

echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");

}

//print_r($_COOKIE); print array

//print $_COOKIE["js"]; print cookie value

?>
</body>
</html>

Thanks

Jona
07-11-2003, 01:30 PM
<?PHP
$js = $_GET["js"];
if($js==0){
setcookie("js", 0, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ("<html>
<head><title>Here is the site with JavaScript disabled.</title></head>
<body><p align=\"justify\">Since you have JavaScript disabled, this site will be completely compatible for you and your specific needs, including but not limited to, audio and braille browser compatibility. Have fun!</p></body></html>");
} else if($js==1) {
setcookie("js", 1, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ("<html><head><title>Here is the site with JavaScript enabled.</title></head><body><p align=\"justify\">Since you have JavaScript enabled, this site will be completely enhanced with powerful JavaScript applications and etcetera visual eye-candy. I hope you enjoy it!</p></body></html>");
} else {
echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");
}
echo $_COOKIE["js"]; print cookie value
?>
</body>
</html>


[J]ona

Tasmanian Devil
07-11-2003, 01:43 PM
Jona~
Sorry to be a pain in the rear, but what the heck am I doing wrong, now I get a phrase error.

Jona
07-11-2003, 01:46 PM
My bad, I didn't comment the end of this line:


echo $_COOKIE["js"]; // print cookie value


[J]ona

Tasmanian Devil
07-11-2003, 02:04 PM
Jona~
Just to throw a ringer in, how do I make it work with frames?

<html>
<head>
<title>Fox Valley Newspapers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset cols="134,*" frameborder="NO" border="0" framespacing="0" rows="*">
<frame name="leftFrame" scrolling="NO" noresize src="index-2.html">
<frame name="mainFrame" src="index-1.html">
</frameset>
<noframes>
<body bgcolor="#FFFFFF" text="#000000">


<?PHP
$js = $_GET["js"];
if($js==0){
setcookie("js", 0, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ("<html>
<head><title>Here is the site with JavaScript disabled.</title></head>
<body><p align=\"justify\">Since you have JavaScript disabled, this site will be completely compatible for you and your specific needs, including but not limited to, audio and braille browser compatibility. Have fun!</p></body></html>");
} else if($js==1) {
setcookie("js", 1, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ("<html><head><title>Here is the site with JavaScript enabled.</title></head><body><p align=\"justify\">Since you have JavaScript enabled, this site will be completely enhanced with powerful JavaScript applications and etcetera visual eye-candy. I hope you enjoy it!</p></body></html>");
} else {
echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");
}
echo $_COOKIE["js"]; // print cookie value
?>

</body>
</noframes>
</html>

Jona
07-11-2003, 02:06 PM
The PHP code must be at the very top of all of your code; otherwise, it will not work. The part where it echoes the page (<html><head>, etc.) is what you use to write the frames.

[J]ona

Tasmanian Devil
07-11-2003, 02:14 PM
Jona~
Not real sure what you mean but this is what I have so far:

<?PHP
$js = $_GET["js"];
if($js==0){
setcookie("js", 0, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ("<html>
<head><title>Here is the site with JavaScript disabled.</title></head>
<body><p align=\"justify\">Since you have JavaScript disabled, this site will be completely compatible for you and your specific needs, including but not limited to, audio and braille browser compatibility. Have fun!</p></body></html>");
} else if($js==1) {
setcookie("js", 1, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ("<html><head><title>Here is the site with JavaScript enabled.</title></head><body><p align=\"justify\">Since you have JavaScript enabled, this site will be completely enhanced with powerful JavaScript applications and etcetera visual eye-candy. I hope you enjoy it!</p></body></html>");
} else {
echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");
}
echo $_COOKIE["js"]; // print cookie value
?>

<html>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset cols="134,*" frameborder="NO" border="0" framespacing="0" rows="*">
<frame name="leftFrame" scrolling="NO" noresize src="index-2.html">
<frame name="mainFrame" src="index-1.html">
</frameset>
<noframes>
<body bgcolor="#FFFFFF" text="#000000">

</body>
</noframes>
</html>

Jona
07-11-2003, 02:23 PM
<?PHP
$js = $_GET["js"];
if($js==0){
setcookie("js", 0, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ('<html>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset cols="134,*" frameborder="NO" border="0" framespacing="0" rows="*">
<frame name="leftFrame" scrolling="NO" noresize src="index-2.html">
<frame name="mainFrame" src="index-noJavaScript.html">
</frameset>
<noframes>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</noframes>
</html>');
} else if($js==1) {
setcookie("js", 1, time()+60*60*24*30, '/', '.foxvalleynews.com');
echo ('<html>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset cols="134,*" frameborder="NO" border="0" framespacing="0" rows="*">
<frame name="leftFrame" scrolling="NO" noresize src="index-2.html">
<frame name="mainFrame" src="index-withJavaScript.html">
</frameset>
<noframes>
<body bgcolor="#FFFFFF" text="#000000">

</body>
</noframes>
</html>');
} else {
echo ("<h1>Please click <a href=\"jsEnabled.php\">here</a></h1>");
}
echo $_COOKIE["js"]; // print cookie value
?>


[J]ona

Tasmanian Devil
07-11-2003, 02:36 PM
Jona~
Your the man!!! :)


P.s. if you have time I have one other Javascript problem, if you don't mind and have time

Jona
07-11-2003, 02:37 PM
Shoot for it. I'm here. :)

[J]ona

Tasmanian Devil
07-11-2003, 02:51 PM
Jona~
I would like this script to work in ALL broswers not just IE4+ and NS6, can you help me?

<body background="back.gif">
<script language="Javascript">

var background = "/back.gif";
var speed = 0;

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

if (browserName != "Netscape" || browserVer >= 6) {

function moveback(movert,movedn,hPos,vPos) {

if (arguments[4])
document.body.style.backgroundImage = "url(\"" + arguments[4] + "\")";

if (arguments[5])
document.body.style.backgroundRepeat = arguments[5]

if (!isNaN(hPos)) {
if ((movert!=0) && (hPos>0)) hPos=-100000
hPos += movert
}
if (!isNaN(vPos)) {
if ((movedn!=0) && (vPos>0)) vPos=-100000
vPos+= movedn
}

document.body.style.backgroundPosition= hPos + " " + vPos
if (isNaN(hPos)) hPos = "\"" + hPos + "\""
if (isNaN(vPos)) vPos = "\"" + vPos + "\""
setTimeout("moveback("+movert+","+movedn+","+hPos+","+vPos+")",speed)
}

moveback(1,1,0,0, background);
}
</script>

Jona
07-11-2003, 03:01 PM
Uh... You mean you want it to work in NN4?

[J]ona

Tasmanian Devil
07-11-2003, 03:08 PM
Jona~
My friend that helped me with that script told me that those were the only broswers that it work in, is she wrong? I do not have NS at all so can not check it.

Thanks

Jona
07-11-2003, 03:11 PM
I don't think it would work in NN4. I don't have the browser either, so as you, I cannot test it. However, NN4 does not have full support for the DOM level I (one), unless I'm mistaken, and it does not fully support CSS1 (at least, I don't think it does). So it probably won't work because it simply didn't include all that was added to the newer versions of CSS. Although, I could be proven wrong...

[J]ona

Tasmanian Devil
07-11-2003, 03:24 PM
Jona~
So that script would only work with IE4+ and NS6?

Jona
07-11-2003, 03:27 PM
As far as I can tell, yes.

[J]ona

Tasmanian Devil
07-11-2003, 03:36 PM
Jona~
That is ok, but can not get it to work in IE. Help

Thanks

Jona
07-11-2003, 03:44 PM
It works for me in IE.

[J]ona

Tasmanian Devil
07-11-2003, 04:09 PM
Jona~
I did get it working, Thank you so much for your help.
Devil

Jona
07-11-2003, 04:20 PM
You're welcome.

[J]ona