www.webdeveloper.com
Results 1 to 5 of 5

Thread: Code for rollover & link requires open in new tab/window

  1. #1
    Join Date
    Nov 2011
    Posts
    3

    Code for rollover & link requires open in new tab/window

    Hello,

    I'm VERY new at this, so I apologize in advance if I'm not even asking this question right, or if I'm on the wrong forum.

    I've got this code that allows me to create an image rollover and link that image to a website. However, I'd like to be able to have the website that it links to open in a new window/tab. Does anyone know how I could tweak this code to accomodate that?

    Thank you!

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    loadImage1 = new Image();
    loadImage1.src="http://my_button_image_rollover.jpg";
    staticImage1 = new Image();
    staticImage1.src="http://my_button_image.jpg";
    // End -->
    </script>
    <a href="http://www.mywebsite.com/" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;">
    <img name="image1" src="http://my_button_image" border=0></a>

  2. #2
    Join Date
    Nov 2011
    Posts
    19
    Easier is add target="_blank" attribute:

    Code:
    <a href="http://www.mywebsite.com/" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;" tagret="_blank">
    <img name="image1" src="http://my_button_image" border=0></a>
    -------------
    Jacek Jeznach
    Web developer

  3. #3
    Join Date
    Nov 2011
    Posts
    3
    Thanks, jeznacki13! I can't get it to work though for some reason. It doesn't show my rollover state and still won't open in a new window. No clue what I could be doing wrong.

    Quote Originally Posted by jeznacki13 View Post
    Easier is add target="_blank" attribute:

    Code:
    <a href="http://www.mywebsite.com/" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;" tagret="_blank">
    <img name="image1" src="http://my_button_image" border=0></a>
    -------------
    Jacek Jeznach
    Web developer

  4. #4
    Join Date
    Nov 2011
    Posts
    19
    Hi

    Sorry for bug, one letter need change:

    tagret="_blank"

    onto

    target="_blank"

    Fixed code here:
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    loadImage1 = new Image();
    loadImage1.src="http://my_button_image_rollover.jpg";
    staticImage1 = new Image();
    staticImage1.src="http://my_button_image.jpg";
    // End -->
    </script>
    <a href="http://www.mywebsite.com/" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;" target="_blank">
    <img name="image1" src="http://my_button_image" border=0></a>
    Looks working fine now.

    -------------
    Jacek Jeznach
    Web developer

  5. #5
    Join Date
    Nov 2011
    Posts
    3
    YES! It works perfectly! You're awesome.


    Quote Originally Posted by jeznacki13 View Post
    Hi

    Sorry for bug, one letter need change:

    tagret="_blank"

    onto

    target="_blank"

    Fixed code here:
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    loadImage1 = new Image();
    loadImage1.src="http://my_button_image_rollover.jpg";
    staticImage1 = new Image();
    staticImage1.src="http://my_button_image.jpg";
    // End -->
    </script>
    <a href="http://www.mywebsite.com/" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;" target="_blank">
    <img name="image1" src="http://my_button_image" border=0></a>
    Looks working fine now.

    -------------
    Jacek Jeznach
    Web developer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles