Page 1 of 1

I need a little help

Posted: Sat Nov 29, 2008 3:32 pm
by PlagueInfected
I'm still brand new to PHP and am trying to get javascript into my php script and so far it isn't working for me. I tried a couple things for it and so far no success =[

here is the first script I tried...

<?php
header("Content-Type: text/javascript");

function clickIE4(){
if (event.button==2){
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")


?>


here is trhe second one I did...

<?php
header("Content-Type: application/x-javascript");

function clickIE4(){
if (event.button==2){
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")


?>

the script is to disable right click and I tried it on my website plagueinfected.com and nothing worked

any help would be ace

Re: I need a little help

Posted: Sat Nov 29, 2008 3:51 pm
by maingroup
put all of your js codes in echo ' your js codes here';

Instead of mixing your php, js together, have you thought about another approach like:

<html>
<script load your external js file here>
<?php
?>
</html>

Re: I need a little help

Posted: Sat Nov 29, 2008 3:54 pm
by PlagueInfected
ya I originally did it as the external script ref tag link, but wanted to try something new with the script. I learned it fast with CSS into PHP code but with javascript. i have had no luck

i also wanted to try and hide the js too within the php script, if i called an echo the javascript would be read off the server as is wouldn't it?