JS File

B

Big-dog1965

Can someone help me here Ive tried several differant things and I get error
on line 1 and 46. This is the JS file I want to use for about 10 pages and
didnt really want the code viewed from view source.

//Disable right click script
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

// Disable Text Selection script- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)
//Add this script to the HEAD section of your page:
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}

//With the script installed, just call the function disableSelection(target)
at the very end of the //document with a reference to the element you wish to
disable text within. A few examples:
//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text
selection on element with id="mydiv"

//</script><script type="text/javascript">
//var somediv=document.getElementById("mydiv")
//disableSelection(somediv) //disable text selection within DIV with
id="mydiv"

//</script><script type="text/javascript">
//var alltables=document.getElementsByTagName("table")
//for (var i=0; i<alltables.length; i++)
//disableSelection(alltables) //disable text selection within all tables
on the page
//</script>Make sure to call the above functions at the end of the document
to ensure the element in //which to disable text for is defined before the
function is called.

//This example will randomly load image1.jpg through image99.jpg. Just
place this JavaScript where you want the image.
nRandom = Math.ceil(Math.random() * 99);
document.write ('<img src="image' + nRandom + '.jpg">');

//Easy Email Scrambler script
//Put at very bottom of page after all links
//Simply edit your "mailto:" links with "encrypted" email addresses such as:
//<a href="mailto:help[at]website.com">my email</a>
var maildivider="[at]" //enter divider you use to divide your email address
strings
for (i=0; i<=(document.links.length-1); i++){
if (document.links.href.indexOf(maildivider)!=-1)
document.links.href=document.links.href.split(maildivider)[0]+"@"+document.links.href.split(maildivider)[1]
}
 
T

Thomas A. Rowe

You are going to have problem using this method, since some of the scripts are required to be in the
head section and some at the end of your page. When you link to a JS file, this places the content
in the head section.

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


Big-dog1965 said:
Can someone help me here Ive tried several differant things and I get error
on line 1 and 46. This is the JS file I want to use for about 10 pages and
didnt really want the code viewed from view source.

//Disable right click script
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

// Disable Text Selection script- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)
//Add this script to the HEAD section of your page:
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}

//With the script installed, just call the function disableSelection(target)
at the very end of the //document with a reference to the element you wish to
disable text within. A few examples:
//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text
selection on element with id="mydiv"

//</script><script type="text/javascript">
//var somediv=document.getElementById("mydiv")
//disableSelection(somediv) //disable text selection within DIV with
id="mydiv"

//</script><script type="text/javascript">
//var alltables=document.getElementsByTagName("table")
//for (var i=0; i<alltables.length; i++)
//disableSelection(alltables) //disable text selection within all tables
on the page
//</script>Make sure to call the above functions at the end of the document
to ensure the element in //which to disable text for is defined before the
function is called.

//This example will randomly load image1.jpg through image99.jpg. Just
place this JavaScript where you want the image.
nRandom = Math.ceil(Math.random() * 99);
document.write ('<img src="image' + nRandom + '.jpg">');

//Easy Email Scrambler script
//Put at very bottom of page after all links
//Simply edit your "mailto:" links with "encrypted" email addresses such as:
//<a href="mailto:help[at]website.com">my email</a>
var maildivider="[at]" //enter divider you use to divide your email address
strings
for (i=0; i<=(document.links.length-1); i++){
if (document.links.href.indexOf(maildivider)!=-1)
document.links.href=document.links.href.split(maildivider)[0]+"@"+document.links.href.split(maildivider)[1]
}
 
B

Big-dog1965

Is there another way to do this using an external file like JS or something
then

Thomas A. Rowe said:
You are going to have problem using this method, since some of the scripts are required to be in the
head section and some at the end of your page. When you link to a JS file, this places the content
in the head section.

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


Big-dog1965 said:
Can someone help me here Ive tried several differant things and I get error
on line 1 and 46. This is the JS file I want to use for about 10 pages and
didnt really want the code viewed from view source.

//Disable right click script
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

// Disable Text Selection script- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)
//Add this script to the HEAD section of your page:
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}

//With the script installed, just call the function disableSelection(target)
at the very end of the //document with a reference to the element you wish to
disable text within. A few examples:
//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text
selection on element with id="mydiv"

//</script><script type="text/javascript">
//var somediv=document.getElementById("mydiv")
//disableSelection(somediv) //disable text selection within DIV with
id="mydiv"

//</script><script type="text/javascript">
//var alltables=document.getElementsByTagName("table")
//for (var i=0; i<alltables.length; i++)
//disableSelection(alltables) //disable text selection within all tables
on the page
//</script>Make sure to call the above functions at the end of the document
to ensure the element in //which to disable text for is defined before the
function is called.

//This example will randomly load image1.jpg through image99.jpg. Just
place this JavaScript where you want the image.
nRandom = Math.ceil(Math.random() * 99);
document.write ('<img src="image' + nRandom + '.jpg">');

//Easy Email Scrambler script
//Put at very bottom of page after all links
//Simply edit your "mailto:" links with "encrypted" email addresses such as:
//<a href="mailto:help[at]website.com">my email</a>
var maildivider="[at]" //enter divider you use to divide your email address
strings
for (i=0; i<=(document.links.length-1); i++){
if (document.links.href.indexOf(maildivider)!=-1)
document.links.href=document.links.href.split(maildivider)[0]+"@"+document.links.href.split(maildivider)[1]
}

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top