mr curious
01-15-2011, 02:25 PM
Hey all,
i've got 2 onclick functions that are conflicting. i'm not really sure how to add the event handlers, i've tried a whole bunch of things but obviously i'm missing something.
my 2 function are:
the first one is for horizontal scrolling, and is kept in a seperate js file called thw.js http://code.google.com/p/wplatformer/source/browse/js/thw.js?spec=svn1bf0fa996cab30ccef0c4b07255e4d03a48bfc07&r=1bf0fa996cab30ccef0c4b07255e4d03a48bfc07
the second one is a short function to change a tag's class name, used for links:
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var Lst;
function CngClass(obj){
if (Lst) Lst.className='';
obj.className='selected';
Lst=obj;
}
/*]]>*/
</script></head>
<body>
<style type="text/css">
#nav .selected { opacity:1.00;}
</style>
<div id="nav">
<a href="#home" id="hlink" onClick="CngClass(this);" style="margin-left:130px">home</a>
<a href="#foamo" class="flink">foamo</a>
<a href="#book" class="blink">book</a>
<a href="#portfolio" class="plink">portfolio</a>
<a href="#contact" class="clink">contact</a>
</div>
</body>
wat i've got so far in terms of the event handler is:
<script type="text/javascript">
function addEventHandler(obj, eventName,handler){
if (document.attachEvent){
obj.attachEvent("on" + eventName, handler);
} else if (document.addEventListener) {
obj.addEventListener(eventName, handler, false);
}
}
</script>
<script type="text/javascript">
window.onload = myonload;
function myonload(){
addEventHandler(submit, "click" , function(){CngClass(obj)});
}
</script>
any help plz..
mc
i've got 2 onclick functions that are conflicting. i'm not really sure how to add the event handlers, i've tried a whole bunch of things but obviously i'm missing something.
my 2 function are:
the first one is for horizontal scrolling, and is kept in a seperate js file called thw.js http://code.google.com/p/wplatformer/source/browse/js/thw.js?spec=svn1bf0fa996cab30ccef0c4b07255e4d03a48bfc07&r=1bf0fa996cab30ccef0c4b07255e4d03a48bfc07
the second one is a short function to change a tag's class name, used for links:
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var Lst;
function CngClass(obj){
if (Lst) Lst.className='';
obj.className='selected';
Lst=obj;
}
/*]]>*/
</script></head>
<body>
<style type="text/css">
#nav .selected { opacity:1.00;}
</style>
<div id="nav">
<a href="#home" id="hlink" onClick="CngClass(this);" style="margin-left:130px">home</a>
<a href="#foamo" class="flink">foamo</a>
<a href="#book" class="blink">book</a>
<a href="#portfolio" class="plink">portfolio</a>
<a href="#contact" class="clink">contact</a>
</div>
</body>
wat i've got so far in terms of the event handler is:
<script type="text/javascript">
function addEventHandler(obj, eventName,handler){
if (document.attachEvent){
obj.attachEvent("on" + eventName, handler);
} else if (document.addEventListener) {
obj.addEventListener(eventName, handler, false);
}
}
</script>
<script type="text/javascript">
window.onload = myonload;
function myonload(){
addEventHandler(submit, "click" , function(){CngClass(obj)});
}
</script>
any help plz..
mc