Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
more than one script on a page?
Old 02-20-2003, 11:15 AM more than one script on a page?
Joe Hussar's Avatar
Skilled Talker

Posts: 69
Location: Chuluota, Florida
Trades: 0
Hi..........

I'm an "amateur" user..........I've been able to use a number of Java scripts on my web site quite successfully......but have a problem and hope someone can help.

Is it possible to have 2 different java scripts on the same web page? On the page in question I have a script that fades in/out several short massages. I've been trying to also use a script, on the same page, that disables "right click" on images.

When I install the disable right click script, the fading text script stops functioning. Nothing shows at all. Either script works fine by itself but when I load both (each within it's own SCRIPT and /SCRIPT tags) the no right click works, but the fading text is no longer there. I've tried installing the scripts in different order (which is listed 1st in the HEAD section), but it makes no difference.

Any ideas??

Thanks!
Joe Hussar
candywebster@aol.com
__________________
Joe Hussar
http://www.candylandcrafts.com/
Joe Hussar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-20-2003, 07:20 PM
yasha78's Avatar
Super Talker

Posts: 114
Trades: 0
hmmm.... this can be very easy or very complicated.

you gotta check the code so that to see that it doesn't clash. If you don't know javascript, this can be a tough one for you -- post the scripts here, maybe someone will help.

Also, encapsulating them into separate script tags doesn't really do anything -- it doesn't matter whether you use sepatate script tags for two of them.
__________________
-yasha78
Ad-Network reviews:
Please login or register to view this content. Registration is FREE
- Last Updated:
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
yasha78 is offline
Reply With Quote
View Public Profile Visit yasha78's homepage!
 
Old 02-21-2003, 08:50 AM 2 java scripts on the same page
Joe Hussar's Avatar
Skilled Talker

Posts: 69
Location: Chuluota, Florida
Trades: 0
I've included the scripts below. .......... I'm not really familiar with Java (am the copy and paste type)...........I was hoping the solution would jump out at someone!
************************************************
A) Here is the code for the "No Right Click"

FIRST: Copy the script below into the HEAD section:

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function right(e) {
var msg1 = "Want to use an image? Please contact: candywebster@aol.com";
if (navigator.appName == 'Netscape' && e.which == 3) {
alert(msg1);
return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
alert(msg1);
return false;
}
else return true;
}

function trap()
{
if(document.images)
{
for(i=0;i<document.images.length;i++)
{
document.images[i].onmousedown = right;
document.images[i].onmouseup = right;
}
}
}
// End -->
</SCRIPT>


THEN: Copy the section below into the BODY section:

onLoad="trap()"



B) Here is the code for the scrolling text:

FIRST: This goes in the HEAD Section:

<script LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Ken Tholke, kentholke@firstsaga.com. -->

<!-- Begin
// add as many or as few messages as you would like
var msg=new Array()
msg[0]="<CENTER>No matter what you need you'll find it at</CENTER>";
msg[1]="<CENTER>Candyland Crafts your one stop Shopping Center!</CENTER>";
msg[2]="<CENTER>If you can't find it please ask...........we want you to enjoy your visit.</CENTER>";
msg[3]="<CENTER> Have a wonderful day!!</CENTER>";

// set your first set of colors. Use as many or as few as you wish.
var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff",
"8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222ff", "1111ff", "0000ff")

//set your second set of colors
// *** must have exactly the same number of colors as the array above ***
var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc", "ffbbbb", "ffaaaa", "ff9999",
"ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333", "ff2222", "ff1111", "ff0000")

//set the height of the display in pixels
high=60;

//set the width of the display in pixels
wide=550;

//set the pixel coordinates for the upper left hand corner of the display
Xpos=170;
Ypos=180;

// move the display away from the edges of the background
pad=15;

// set the background color of the display
bgcol="ffffff";

//add a background image if you want.
// *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
cellbg="faderbg.jpg";

// set the font
fntFam="verdana,helvetica,arial";
fntSize=14;

// set how how many seconds you want the message to stay remain at totality.
pause=2.5;


// Do not edit these values below!!!

icolor=0;
mcolor=1;
imsg=0;
spWidth=wide-(2*pad);
totality=false;
glowing=true;
var theMsg="";
var cellcontent="";
pause=pause*1000;
if(cellbg.length>4){cellbg=" background="+cellbg}
else{cellbg="";}

function doPause(){
totality=false; t=setTimeout("changecolor()",pause);
}
function initiate(){
getContentColor();
getMsg();
getCellContent();
if(document.all){
msgbg.innerHTML=cellcontent;
msgfade.innerHTML=theMsg;
msgbg.style.posLeft=Xpos;
msgbg.style.posTop=Ypos;
msgfade.style.posLeft=Xpos+pad;
msgfade.style.posTop=Ypos+pad;
t=setTimeout("changecolor()",50);}
if(document.layers){
document.msgbg.document.write(cellcontent);
document.msgbg.document.close();
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
document.msgbg.left=Xpos;
document.msgbg.top=Ypos;
document.msgfade.left=Xpos+pad;
document.msgfade.top=Ypos+pad;
t=setTimeout("changecolor()",100);}
}
function changecolor(){
if(totality==true){doPause();}
else{
getMsg();
getContentColor();
if(document.all){
msgfade.innerHTML=theMsg;
t=setTimeout("changecolor()",50);}
if(document.layers){
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
t=setTimeout("changecolor()",70);}
}
}
function getFadeColor(){
icolor=icolor-1;
if(mcolor==1){contentcolor=colors1[icolor];}
else{contentcolor=colors2[icolor];}
}
function getGlowColor(){
icolor=icolor+1;
if(mcolor==1){contentcolor=colors1[icolor];}
else{contentcolor=colors2[icolor];}
}
function changemsg(){
if(imsg==msg.length-1){imsg=0; mcolor=1;}
else if(imsg != msg.lenght-1 && mcolor==1){imsg=imsg+1; mcolor=0;}
else{imsg=imsg+1; mcolor=1;}
}
function getContentColor(){
if(icolor==colors1.length-1 && glowing==true){
getFadeColor(); glowing=false; totality=true;}
else if(icolor < colors1.length && glowing==true){
getGlowColor();}
else if(icolor < 1 && glowing==false){changemsg(); getGlowColor(); glowing=true;}
else{getFadeColor();}
}
function getMsg() {
theMsg="<span style='font-size:"+fntSize+"pt; font-family:"+fntFam+"; width:"+spWidth+";'>"
theMsg+="<B><font color="+contentcolor+">"+msg[imsg]+"</font></B> "
theMsg+="</span>"
}
function getCellContent(){
cellcontent="<TABLE height="+high+
" width="+wide+" bgcolor="+bgcol+" cellpadding=0 cellspacing=0><TR><TD"+cellbg+"> </TD></TR></TABLE>"}
// End -->
</script>

SECOND: This [on load event handler?] goes in the BODY Section:

onload="initiate()"

THIRD: Copy this into the BODY of the html page:

<div id="msgbg" style="position: absolute;">
</div>
<div id="msgfade" style="position: absolute;">
</div>
__________________
Joe Hussar
http://www.candylandcrafts.com/
Joe Hussar is offline
Reply With Quote
View Public Profile
 
Old 02-21-2003, 10:42 PM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Trades: 0
Hi Joe,

Check to make sure that there aren't any variables that are shared between the two scripts.
__________________

Please login or register to view this content. Registration is FREE
- Affordable feature-packed remotely hosted message boards!
conkermaniac is offline
Reply With Quote
View Public Profile
 
Old 03-05-2003, 11:20 AM
Junior Talker

Posts: 4
Location: UK
Trades: 0
The problem may be with your onLoad handler in your <BODY tag.

I'm not sure (although I may well be wrong) that you can decalre onLoad twice (if that is in fact what your doing).

Try something like:

<BODY onLoad="trap(); initiate();">

you could even make a call to initiate() from your trap function by putting:
initiate();
after:
function trap()
{

Hope this helps
__________________
Can't sleep, clowns will eat me.
MrBenn is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to more than one script on a page?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67955 seconds with 12 queries