Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 06-24-2008, 03:09 PM   #1 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
running multiple javascripts

I have a simple webpage that where i am using one javascript to control the rollover buttons, another to control a expandable and collapsible sub menu and i would like to use a third which would allow a contact button to stay at the top right hand corner of the site no matter the scrolling, it will float and follow.

initially, the first two scripts were canceling each other out, so i added an onLoad-function1(); function2() (or something to that affect) to the body tag, but now my code will not validate.

any suggestions on making all three of these work at the same time?

they are externally being called in to the index.

thanks, and im new to the forum, great to be here.
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 06-25-2008, 12:05 AM   #2 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
Welcome to v7n, Chuco!

To solve your problem and validate your page, add the following script into the head tag of your page:


Code:
window.onload = function() { // Call every function you need here. // control the rollover buttons: rolloverButtons(); // expand collapse the submenu expandCollapse(); // contact button contactButton(); };
Of course, you have to rename those functions with your own functions' names.
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-25-2008, 12:08 AM   #3 (permalink)
v7n Mentor
 
Join Date: 09-03-07
Location: England
Posts: 528
iTrader: 0 / 0%
Latest Blog:
None

Boogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really nice
Ah cost you didn't let me use your wisdom to explain it did you- too fast!
__________________
Great new 'June' Javascript Framework

June Forums - Innovative JScripting

Price is what you pay... Value is what you get.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-25-2008, 12:18 AM   #4 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
hehe!!
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-27-2008, 11:59 AM   #5 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
so i just paste in the appropriate javascript?

am i supposed to leave the () in after the vode?

thanks alot!!!
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-27-2008, 04:41 PM   #6 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
Yes. All you have to do is to replace:

Code:
rolloverButtons(); expandCollapse(); contactButton();

with your own functions names. And yes, you must leave the brackets in place. They mean something like : execute the function which name is in front of me. ok
?
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-30-2008, 10:12 AM   #7 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
GREAT! thanks so much.

so to clarify the function name is the name of the javascript like script1.js or is there another way to name these within the .js code to be called in the html?

sorry i dont know too much about javascript, i only know how to tweak them. much appreciated.
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-02-2008, 04:46 PM   #8 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
so to clarify the function name is the name of the javascript like script1.js or is there another way to name these within the .js code to be called into the html?
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-03-2008, 09:14 AM   #9 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
Code:
<script src="myScript.js" type="text/javascript"></script> <script id="WindowLoad" type="text/javascript"> // The following three functions can either be hard-coded in your page // or in the myScript.js file. function function1() { // code here something } function function2() { // code here something } function function3() { // code here something } window.onload = function() { function1(); // execute function 1. function2(); // execute function 2. function3(); // execute function 3. }; </script>
hth.
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-06-2008, 10:00 PM   #10 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
so this is what i have at the head of my html:
<script src="scripts/myScript.js" type="text/javascript"></script>

(i have nothing else at the head aside from a css call.)

This is what i have in my external javascript doc:

// JavaScript Document
<script id="WindowLoad" type="text/javascript">

// The following three functions can either be hard-coded in your page
// or in the myScript.js file.

function function1() {
function MM_swapImgRestore() { //v3.0
var u,x,w=document.MM_sr; for(u=0;w&&u<w.length&&(x=w[u])&&x.oSrc;u++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var u,j=d.MM_p.length,w=MM_preloadImages.arguments; for(u=0; u<w.length; u++)
if (w[u].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=w[u];}}
}

function MM_findObj(n, d) { //v4.01
var p,u,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (u=0;!x&&u<d.forms.length;u++) x=d.forms[u][n];
for(u=0;!x&&d.layers&&u<d.layers.length;u++) x=MM_findObj(n,d.layers[u].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var u,j=0,x,w=MM_swapImage.arguments; document.MM_sr=new Array; for(u=0;u<(w.length-2);u+=3)
if ((x=MM_findObj(w[u]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=w[u+2];}
}
}
function function2() {
if(!window.Node){
var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}

function checkNode(node, filter){
return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}

function getChildren(node, filter){
var result = new Array();
var children = node.childNodes;
for(var i = 0; i < children.length; i++){
if(checkNode(children[i], filter)) result[result.length] = children[i];
}
return result;
}

function getChildrenByElement(node){
return getChildren(node, "ELEMENT_NODE");
}

function getFirstChild(node, filter){
var child;
var children = node.childNodes;
for(var i = 0; i < children.length; i++){
child = children[i];
if(checkNode(child, filter)) return child;
}
return null;
}

function getFirstChildByText(node){
return getFirstChild(node, "TEXT_NODE");
}

function getNextSibling(node, filter){
for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
if(checkNode(sibling, filter)) return sibling;
}
return null;
}
function getNextSiblingByElement(node){
return getNextSibling(node, "ELEMENT_NODE");
}

// Menu Functions & Properties

var activeMenu = null;

function showMenu() {
if(activeMenu){
activeMenu.className = "";
getNextSiblingByElement(activeMenu).style.display = "none";
}
if(this == activeMenu){
activeMenu = null;
} else {
this.className = "active";
getNextSiblingByElement(this).style.display = "block";
activeMenu = this;
}
return false;
}

function initMenu(){
var menus, menu, text, a, i;
menus = getChildrenByElement(document.getElementById("menu "));
for(i = 0; i < menus.length; i++){
menu = menus[i];
text = getFirstChildByText(menu);
a = document.createElement("a");
menu.replaceChild(a, text);
a.appendChild(text);
a.href = "#";
a.onclick = showMenu;
a.onfocus = function(){this.blur()};
}
}

if(document.createElement) window.onload = initMenu;
}
function function3() {
// code here something
}


window.onload = function() {
function1(); // execute function 1.
function2(); // execute function 2.
function3(); // execute function 3.
};

</script>

----------------------------------------------------------
WHAT AM I DOING WRONG???
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-07-2008, 11:58 AM   #11 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
anyone?
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-07-2008, 12:23 PM   #12 (permalink)
v7n Mentor
 
Join Date: 07-24-06
Posts: 686
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nice
You don't need the script tag in your external document.
nasty.web is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-07-2008, 03:43 PM   #13 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
at the top or the bottom or both?

i tried it all three ways and still couldnt get it to work
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-07-2008, 08:03 PM   #14 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
He meant that you don't need this : "<script src="scripts/myScript.js" type="text/javascript"></script>" while you have all those functions in the page header.

As about your question:
-- replace the window.onload function with this :

Code:
window.onload = function() { function1(); function2(); initMenu(); };
hth, because I really hate DW's generated code.
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-08-2008, 04:41 PM   #15 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
ideally i would like to have it called in externally, so how would my html page look and how would my external javascript page look?

sorry this has become more of a problem than i had anticipated.

thanks so much for everyones help so far!
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-09-2008, 04:11 AM   #16 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
the content of the external script file named myScript.js that will be saved in the scripts folder:
Code:
function function1() { function MM_swapImgRestore() { //v3.0 var u,x,w=document.MM_sr; for(u=0;w&&u<w.length&&(x=w[u])&&x.oSrc;u++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var u,j=d.MM_p.length,w=MM_preloadImages.arguments; for(u=0; u<w.length; u++) if (w[u].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=w[u];}} } function MM_findObj(n, d) { //v4.01 var p,u,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (u=0;!x&&u<d.forms.length;u++) x=d.forms[u][n]; for(u=0;!x&&d.layers&&u<d.layers.length;u++) x=MM_findObj(n,d.layers[u].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var u,j=0,x,w=MM_swapImage.arguments; document.MM_sr=new Array; for(u=0;u<(w.length-2);u+=3) if ((x=MM_findObj(w[u]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=w[u+2];} } } function function2() { if(!window.Node){ var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3}; } function checkNode(node, filter){ return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase()); } function getChildren(node, filter){ var result = new Array(); var children = node.childNodes; for(var i = 0; i < children.length; i++){ if(checkNode(children[i], filter)) result[result.length] = children[i]; } return result; } function getChildrenByElement(node){ return getChildren(node, "ELEMENT_NODE"); } function getFirstChild(node, filter){ var child; var children = node.childNodes; for(var i = 0; i < children.length; i++){ child = children[i]; if(checkNode(child, filter)) return child; } return null; } function getFirstChildByText(node){ return getFirstChild(node, "TEXT_NODE"); } function getNextSibling(node, filter){ for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){ if(checkNode(sibling, filter)) return sibling; } return null; } function getNextSiblingByElement(node){ return getNextSibling(node, "ELEMENT_NODE"); } // Menu Functions & Properties var activeMenu = null; function showMenu() { if(activeMenu){ activeMenu.className = ""; getNextSiblingByElement(activeMenu).style.display = "none"; } if(this == activeMenu){ activeMenu = null; } else { this.className = "active"; getNextSiblingByElement(this).style.display = "block"; activeMenu = this; } return false; } function initMenu(){ var menus, menu, text, a, i; menus = getChildrenByElement(document.getElementById("menu ")); for(i = 0; i < menus.length; i++){ menu = menus[i]; text = getFirstChildByText(menu); a = document.createElement("a"); menu.replaceChild(a, text); a.appendChild(text); a.href = "#"; a.onclick = showMenu; a.onfocus = function(){this.blur()}; } } if(document.createElement) window.onload = initMenu; } function function3() { // code here something }

And now, add this in the head tag of your HTML page:
Code:
<head> <script src="scripts/myScript.js" type="text/javascript"></script> <script type="text/javascript"> window.onload = function() { function1(); function2(); initMenu(); }; </script> <head>
okay?
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-09-2008, 03:11 PM   #17 (permalink)
Contributing Member
 
Join Date: 06-24-08
Posts: 54
iTrader: 0 / 0%
Latest Blog:
None

chuco61 is liked by many
YES! thanks. ill try when i get home.

Thanks a million.
chuco61 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-10-2008, 04:27 AM   #18 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
don't mention it!
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Javascripts Boogle Coding Forum 41 10-31-2007 10:55 PM
Javascripts WANTED!(free, copy paste,)(Random Quotes display, & image change) dudeman Coding Forum 6 09-28-2007 01:15 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 09:49 PM.
© Copyright 2008 V7 Inc