Using OnClick To Put A Link On Button

davearia

Centurion
Joined
Jan 4, 2005
Messages
184
Hi All,

Here is the code in my HTML I am working with:
Visual Basic:
<DIV 
     onmouseup="this.style.backgroundPosition='0 -50px';" 
     class="liknobtn" 
     onmousedown="this.style.backgroundPosition='0 -100px';"
     id="liknobtn_01" 
     onmouseover="this.style.backgroundPosition='0 -50px';" 
     title="Back To Home Page"
     onmouseout="this.style.backgroundPosition='0 0';" 
     runat="server">
</DIV>
I want to move to a URL if the user presses this button. I think it is the OnClick event I should use but I cannot work out what to put in it.

Please help, Dave.
 
I apologise if this post is not appropriate for this site as it is more of javascript issue.

However the fix I needed was:

onClick ="window.navigate('http://www.google.co.uk');"

Thanks, Dave.
 
Hi All,

I modified my HTML to be less ie specific as follows:
Code:
<DIV 
     onmouseup="this.style.backgroundPosition='0 -50px';"
     class="liknobtn"
     onmousedown="this.style.backgroundPosition='0 -100px';"
     id="liknobtn_01"
     onmouseover="this.style.backgroundPosition='0 -50px';"
     title="Back To Home Page"
     onclick="window.location.href('http://localhost/MEB/Default.aspx?Action=Home');"
     style="cursor: pointer;"
     onmouseout="this.style.backgroundPosition='0 0';"
     runat="server">
</DIV>
I have now installed FireFox, NetScape Navigator 8, Opera browsers on my machine to test them.

This code is fine for Internet Explorer but the links do not work for any of the other browsers. :(

I was hoping that this code would be ok in non-ie browsers. What exactly is wrong here?

Thanks, Dave. :) :) :)
 
I made my buttons server controls and added this to my Page_Load:
Visual Basic:
liknobtn_01.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=Home';")
liknobtn_02.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=History';")
liknobtn_03.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=FAQ';")
liknobtn_04.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=AboutUs';")
liknobtn_05.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=PriceAndAvailability';")
liknobtn_06.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=News';")
liknobtn_07.Attributes.Add("onclick", "window.location.href='http://www.bigred.me.uk/MEB/Default.aspx?Action=ContactUs';")
It works great with firefox & Netscape now, however it still does not work in opera. This does not worry me too much as I think most users are browsing with either ie or firefox.

Another irritating issue is my flash banner does not appear in firefox as it does in ie:
Code:
<OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
height="100" width="600" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
     <PARAM NAME="_cx" VALUE="15875">
     <PARAM NAME="_cy" VALUE="2646">
     <PARAM NAME="FlashVars" VALUE="">
     <PARAM NAME="Movie" VALUE="MEB_Banner.swf">
     <PARAM NAME="Src" VALUE="MEB_Banner.swf">
     <PARAM NAME="WMode" VALUE="Window">
     <PARAM NAME="Play" VALUE="-1">
     <PARAM NAME="Loop" VALUE="-1">
     <PARAM NAME="Quality" VALUE="High">
     <PARAM NAME="SAlign" VALUE="">
     <PARAM NAME="Menu" VALUE="-1">
     <PARAM NAME="Base" VALUE="">
     <PARAM NAME="AllowScriptAccess" VALUE="always">
     <PARAM NAME="Scale" VALUE="ShowAll">
     <PARAM NAME="DeviceFont" VALUE="0">
     <PARAM NAME="EmbedMovie" VALUE="0">
     <PARAM NAME="BGColor" VALUE="">
     <PARAM NAME="SWRemote" VALUE="">
     <PARAM NAME="MovieData" VALUE="">
     <PARAM NAME="SeamlessTabbing" VALUE="1">
     <embed src="Movie1.swf"
    quality="high"pluginspage="http://www.macromedia.com/go/getflashplayer"
          type="application/x-shockwave-flash" width="600" height="100">
     </embed>
</OBJECT>
I get warnings in Visual Studio about the quality, pluginspage, type attributes of the embed tag. However ie still runs the flash perfect, firefox does not show the flash at all. The link is: http://www.bigred.me.uk/meb/default.aspx

Please help me fix this.

Thanks, Dave. :D :D :D
 
Hi All,

My fault.

The name for the flash file is wrong in the embed tag. Funny thing is that ie still ran it.

Any way it's fine now.

Thanks, Dave.
 
Back
Top