...

View Full Version : Need script to fire a function



Papajo
06-20-2009, 07:45 PM
Hi
I need this script to fire a "function msg()" instead of displaying the "document.write(enabled)" statement. Any idea's?? Thanks Joe



var cookieEnabled=(navigator.cookieEnabled)? true : false
if (cookieEnabled){
document.write("enabled");
}else{
document.write("disabled");
}

Philip M
06-20-2009, 07:55 PM
var cookieEnabled=(navigator.cookieEnabled)? true : false
if (cookieEnabled){
msg();
}

But why not simply combine the function msg() with this?


var cookieEnabled=(navigator.cookieEnabled)? true : false
if (cookieEnabled){
// show the message
}


"There are a lot of tired legs in those white shirts" - Football commentator

Papajo
06-20-2009, 08:07 PM
Sorry but the script still won't fire with replacing the document.write with msg();
I tried that already, thought it would work also??


var cookieEnabled=(navigator.cookieEnabled)? true : false
if (cookieEnabled){
msg();
}

Philip M
06-20-2009, 08:46 PM
Well, there must be some other problem. You can see that this works:-


<script type = "text/javascript">

var cookieEnabled= true;
if (cookieEnabled){
msg();
}

function msg() {
alert ("My message");
}

</script>

Papajo
06-20-2009, 09:00 PM
Ok I found the problem, I had the javascript before the form tag, I placed it after and the script worked, go figure!!!!
Thanks for your help. Joe



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum