Click in Image to open Link?

Discussion in 'ASP .Net' started by Miguel Dias Moura, Apr 15, 2004.

  1. Hello,

    i have an image with the following code:
    <img src="image/panel.gif" width="20" height="80"
    onClick="fnLoadNewWindow('http://www.google.com');">

    When i click the image the Javascript Function fnLoadNewWindow opens a new
    window with google.com.

    The problem is that the mouse doesn't change when it's over the image to the
    icon that usually shows when the image is a link.

    What am i doing wrong here?

    Thank You,
    Miguel

    P.S: The function works fine. A new windows is opened when i click the
    image.
     
    Miguel Dias Moura, Apr 15, 2004
    #1
    1. Advertising

  2. Hi Miguel,

    An ASP.NET Imagebutton control would give you the effect you want:

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    ImageButton1.Attributes.Add _
    ("onclick", _
    "window.open('http://www.google.com',null," & _
    "'height=200,width=400," & _
    "status=yes,toolbar=no,menubar=no," & _
    "location=no');return false;")
    End Sub


    <form id="Form1" method="post" runat="server">
    <asp:ImageButton id="ImageButton1" runat="server"
    ImageUrl="http://www.google.ca/intl/fr_ca/images/logo.gif"></asp:ImageButton>
    </form>

    Ken
    Microsoft MVP [ASP.NET]


    "Miguel Dias Moura" <> wrote in message
    news:e$...
    > Hello,
    >
    > i have an image with the following code:
    > <img src="image/panel.gif" width="20" height="80"
    > onClick="fnLoadNewWindow('http://www.google.com');">
    >
    > When i click the image the Javascript Function fnLoadNewWindow opens a new
    > window with google.com.
    >
    > The problem is that the mouse doesn't change when it's over the image to
    > the
    > icon that usually shows when the image is a link.
    >
    > What am i doing wrong here?
    >
    > Thank You,
    > Miguel
    >
    > P.S: The function works fine. A new windows is opened when i click the
    > image.
    >
    >
     
    Ken Cox [Microsoft MVP], Apr 15, 2004
    #2
    1. Advertising

  3. Miguel Dias Moura

    Curt_C [MVP] Guest

    style="cursor:'hand';"


    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    www.Darkfalz.com


    "Miguel Dias Moura" <> wrote in message
    news:e$...
    > Hello,
    >
    > i have an image with the following code:
    > <img src="image/panel.gif" width="20" height="80"
    > onClick="fnLoadNewWindow('http://www.google.com');">
    >
    > When i click the image the Javascript Function fnLoadNewWindow opens a new
    > window with google.com.
    >
    > The problem is that the mouse doesn't change when it's over the image to

    the
    > icon that usually shows when the image is a link.
    >
    > What am i doing wrong here?
    >
    > Thank You,
    > Miguel
    >
    > P.S: The function works fine. A new windows is opened when i click the
    > image.
    >
    >
     
    Curt_C [MVP], Apr 15, 2004
    #3
  4. There is a problem. I allready have a form in this page. Can i have 2 forms
    in the same page?

    I am asking this because i got an error.

    Miguel

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hi Miguel,
    >
    > An ASP.NET Imagebutton control would give you the effect you want:
    >
    > Private Sub Page_Load _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) _
    > Handles MyBase.Load
    > ImageButton1.Attributes.Add _
    > ("onclick", _
    > "window.open('http://www.google.com',null," & _
    > "'height=200,width=400," & _
    > "status=yes,toolbar=no,menubar=no," & _
    > "location=no');return false;")
    > End Sub
    >
    >
    > <form id="Form1" method="post" runat="server">
    > <asp:ImageButton id="ImageButton1" runat="server"
    >

    ImageUrl="http://www.google.ca/intl/fr_ca/images/logo.gif"></asp:ImageButton
    >
    > </form>
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    >
    > "Miguel Dias Moura" <> wrote in message
    > news:e$...
    > > Hello,
    > >
    > > i have an image with the following code:
    > > <img src="image/panel.gif" width="20" height="80"
    > > onClick="fnLoadNewWindow('http://www.google.com');">
    > >
    > > When i click the image the Javascript Function fnLoadNewWindow opens a

    new
    > > window with google.com.
    > >
    > > The problem is that the mouse doesn't change when it's over the image to
    > > the
    > > icon that usually shows when the image is a link.
    > >
    > > What am i doing wrong here?
    > >
    > > Thank You,
    > > Miguel
    > >
    > > P.S: The function works fine. A new windows is opened when i click the
    > > image.
    > >
    > >

    >
     
    Miguel Dias Moura, Apr 15, 2004
    #4
  5. Generally speaking, you can only have one form in an asp.net page. Perhaps
    you can show the code that you are trying to make work? It would be easier
    to give advice.

    "Miguel Dias Moura" <> wrote in message
    news:...
    > There is a problem. I allready have a form in this page. Can i have 2
    > forms
    > in the same page?
    >
    > I am asking this because i got an error.
    >
    > Miguel
    >
    > "Ken Cox [Microsoft MVP]" <> wrote in message
    > news:...
    >> Hi Miguel,
    >>
    >> An ASP.NET Imagebutton control would give you the effect you want:
    >>
    >> Private Sub Page_Load _
    >> (ByVal sender As System.Object, _
    >> ByVal e As System.EventArgs) _
    >> Handles MyBase.Load
    >> ImageButton1.Attributes.Add _
    >> ("onclick", _
    >> "window.open('http://www.google.com',null," & _
    >> "'height=200,width=400," & _
    >> "status=yes,toolbar=no,menubar=no," & _
    >> "location=no');return false;")
    >> End Sub
    >>
    >>
    >> <form id="Form1" method="post" runat="server">
    >> <asp:ImageButton id="ImageButton1" runat="server"
    >>

    > ImageUrl="http://www.google.ca/intl/fr_ca/images/logo.gif"></asp:ImageButton
    >>
    >> </form>
    >>
    >> Ken
    >> Microsoft MVP [ASP.NET]
    >>
    >>
    >> "Miguel Dias Moura" <> wrote in message
    >> news:e$...
    >> > Hello,
    >> >
    >> > i have an image with the following code:
    >> > <img src="image/panel.gif" width="20" height="80"
    >> > onClick="fnLoadNewWindow('http://www.google.com');">
    >> >
    >> > When i click the image the Javascript Function fnLoadNewWindow opens a

    > new
    >> > window with google.com.
    >> >
    >> > The problem is that the mouse doesn't change when it's over the image
    >> > to
    >> > the
    >> > icon that usually shows when the image is a link.
    >> >
    >> > What am i doing wrong here?
    >> >
    >> > Thank You,
    >> > Miguel
    >> >
    >> > P.S: The function works fine. A new windows is opened when i click the
    >> > image.
    >> >
    >> >

    >>

    >
    >
     
    Ken Cox [Microsoft MVP], Apr 15, 2004
    #5
  6. You might try using a hyperlink instead. You can specify the image uri
    for the link to use, plus the navigate url, plus the target of "_blank".
    E.g,

    <asp:HyperLink id="HyperLink1" runat="server" NavigateUrl="Search.aspx"
    ImageUrl="search.jpg" Target="_blank">Search</asp:HyperLink>

    or in html,

    <a id="HyperLink1" href="Search.aspx" target="_blank">
    <img src="search.jpg" alt="Search" />
    </a>

    HTH,

    Chad

    Miguel Dias Moura wrote:
    > Hello,
    >
    > i have an image with the following code:
    > <img src="image/panel.gif" width="20" height="80"
    > onClick="fnLoadNewWindow('http://www.google.com');">
    >
    > When i click the image the Javascript Function fnLoadNewWindow opens a new
    > window with google.com.
    >
    > The problem is that the mouse doesn't change when it's over the image to the
    > icon that usually shows when the image is a link.
    >
    > What am i doing wrong here?
    >
    > Thank You,
    > Miguel
    >
    > P.S: The function works fine. A new windows is opened when i click the
    > image.
    >
    >
     
    chad [email at] gosigma.com, Apr 15, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mathew George
    Replies:
    1
    Views:
    2,391
  2. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    954
    Kevin Spencer
    May 17, 2005
  3. Mathew George
    Replies:
    0
    Views:
    178
    Mathew George
    Jul 1, 2003
  4. Blue®
    Replies:
    4
    Views:
    919
    Blue®
    Sep 27, 2003
  5. Peter Michaux

    Synthetic click on link doesn't follow link

    Peter Michaux, Jun 4, 2007, in forum: Javascript
    Replies:
    2
    Views:
    193
    -Lost
    Jun 5, 2007
Loading...

Share This Page