I am copying a menu from a PHP page and adding it as a user control in my ASp website. Since it is a rollover image menu it has some javascript in it. I managed to copy the HTML part to the ascx page but where do i copy the Javascript in the ascx page.
Below is he Menu which is basiclly in HTML and javascript. I copied the HTML part from it and it all works fine. But where do i put the javascript part of it . This is the ascx file:
<%@ Control Language="VB" ClassName="IncHeader" %>
<script type="text/javascript" runat="server">
</script>
<table width="961" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="index.htm"><img src="images/lg_lgcoolclub.jpg" alt="+I2A# LG Cool Club" width="306" height="71" border="0" /></a></td>
<td align="right" valign="middle"><a href="http://www.lge.com/th/" target="_blank" onMouseOver="MM_swapImage('linkmain','','images/btn_link_main_2.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/btn_link_main_1.jpg" alt="@I2*9H@'GDL+%1- LG" name="linkmain" width="158" height="26" border="0" id="linkmain" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td><a href="index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_1','','images/menu_home_2.jpg',1)"><img src="images/menu_home_1.jpg" alt="+I2+%1" name="homemenu_1" width="156" height="48" border="0" id="homemenu_1" /></a></td>
<td><a href="products.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_2','','images/menu_product_2.jpg',1)"><img src="images/menu_product_1.jpg" alt="I-!9%B#(1L LG" name="homemenu_2" width="194" height="48" border="0" id="homemenu_2" /></a></td>
<td><a href="promotion.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_3','','images/menu_pro_2.jpg',1)"><img src="images/menu_pro_1.jpg" alt="B#B!
1H" name="homemenu_3" width="140" height="48" border="0" id="homemenu_3" /></a></td>
<td><a href="news.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_4','','images/menu_news_2.jpg',1)"><img src="images/menu_news_1.jpg" alt="H2'*2# LG" name="homemenu_4" width="149" height="48" border="0" id="homemenu_4" /></a></td>
<td><a href="register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_5','','images/menu_regis_2.jpg',1)"><img src="images/menu_regis_1.jpg" alt="*!1#*!2
4" name="homemenu_5" width="164" height="48" border="0" id="homemenu_5" /></a></td>
<td><a href="contact.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_6','','images/menu_contact_2.jpg',1)"><img src="images/menu_contact_1.jpg" alt="4H-@#2" name="homemenu_6" width="158" height="48" border="0" id="homemenu_6" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="images/space.gif" width="1" height="10" /></td>
</tr>
</table>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,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 (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<body onLoad="MM_preloadImages('images/btn_link_main_2.jpg','images/menu_home_2.jpg','images/menu_product_2.jpg','images/menu_pro_2.jpg','images/menu_news_2.jpg','images/menu_regis_2.jpg','images/menu_contact_2.jpg')"><table width="961" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="index.htm"><img src="images/lg_lgcoolclub.jpg" alt="+I2A# LG Cool Club" width="306" height="71" border="0" /></a></td>
<td align="right" valign="middle"><a href="http://www.lge.com/th/" target="_blank" onMouseOver="MM_swapImage('linkmain','','images/btn_link_main_2.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/btn_link_main_1.jpg" alt="@I2*9H@'GDL+%1- LG" name="linkmain" width="158" height="26" border="0" id="linkmain" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td><a href="index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_1','','images/menu_home_2.jpg',1)"><img src="images/menu_home_1.jpg" alt="+I2+%1" name="homemenu_1" width="156" height="48" border="0" id="homemenu_1" /></a></td>
<td><a href="products.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_2','','images/menu_product_2.jpg',1)"><img src="images/menu_product_1.jpg" alt="I-!9%B#(1L LG" name="homemenu_2" width="194" height="48" border="0" id="homemenu_2" /></a></td>
<td><a href="promotion.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_3','','images/menu_pro_2.jpg',1)"><img src="images/menu_pro_1.jpg" alt="B#B!
1H" name="homemenu_3" width="140" height="48" border="0" id="homemenu_3" /></a></td>
<td><a href="news.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_4','','images/menu_news_2.jpg',1)"><img src="images/menu_news_1.jpg" alt="H2'*2# LG" name="homemenu_4" width="149" height="48" border="0" id="homemenu_4" /></a></td>
<td><a href="register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_5','','images/menu_regis_2.jpg',1)"><img src="images/menu_regis_1.jpg" alt="*!1#*!2
4" name="homemenu_5" width="164" height="48" border="0" id="homemenu_5" /></a></td>
<td><a href="contact.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homemenu_6','','images/menu_contact_2.jpg',1)"><img src="images/menu_contact_1.jpg" alt="4H-@#2" name="homemenu_6" width="158" height="48" border="0" id="homemenu_6" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="images/space.gif" width="1" height="10" /></td>
</tr>
</table>
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
Select allOpen in new window
by: princeatapiPosted on 2009-11-04 at 01:59:46ID: 25737775
Place the scripts in a global location ( say as a .js file ) just include the reference to the page where you are going to use your UserControl