how to make external link with div css

Discussion in 'HTML & Website Design' started by toraniz, Oct 12, 2009.

  1. #1
    Hi webmasters,
    I am trying to make an external link with my div tag as below with java:

    <div id="mydive" onclick="location.href=mylink;" style="cursor:pointer;">
    </div>

    the above link is opening internal but I want to make it open in new windows as an external.
    how this would be possible?
    would be appreciated if you can show it here visualy .
    Thanks for any help.
     
    toraniz, Oct 12, 2009 IP
  2. claire0917

    claire0917 Peon

    Messages:
    137
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    window.open(mylink) should popup a new window.
     
    claire0917, Oct 12, 2009 IP
  3. toraniz

    toraniz Banned

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    Thanks for your comment.
    I did as below but did not work ,am I doing wrong something here:

    <div id=window.open"rightbot2" onclick="location.href='http://yahoo.com';" style="cursor:pointer;">

    Thanks
     
    toraniz, Oct 12, 2009 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Why not just use a DIV tag, put an anchor in there, set the height and width of the anchor and DIV to be the same, and declare the anchor's display state as block?

    No need to use JavaScript then. ;)
     
    Dan Schulz, Oct 12, 2009 IP
  5. toraniz

    toraniz Banned

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    Hi ,Dan ,
    this seems good but I am completly newbie at this things .
    could you please show me the code here .
    Thank you.
     
    toraniz, Oct 12, 2009 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sure can.

    
    <!-- quick and dirty demo; make sure the actual styles are in an external stylesheet and an ID is used on the DIV for the CSS to reference -->
    <div style="height: 480px; width: "640px;">
    	<a href="#" style="background-color: pink; display: block; height: 480px; width: 640px;">Link Text</a>
    </div>
    
    Code (markup):
     
    Dan Schulz, Oct 12, 2009 IP
  7. toraniz

    toraniz Banned

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #7
    Dan , I know this is going to work but I am mess up with the code when inserting into it.
    the actual code for the css that I have is as below and It is show a background image in the div tag:

    #rightbot2{
    background:url(images/rightbot2.jpg) no-repeat center;
    height: 218px;
    color:#FFFFFF;
    padding-top: 30px;
    padding-left: 50px;
    padding-right: 20px;

    could you please show it with the above code .
    many thanks.
     
    toraniz, Oct 13, 2009 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #8
    subtract 30px from the height, then subtract 70px from the width

    (back to bed I go)
     
    Dan Schulz, Oct 13, 2009 IP
  9. toraniz

    toraniz Banned

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #9
    Thanks for your help ,this a perfect.
    regards
     
    toraniz, Oct 14, 2009 IP
  10. leebari

    leebari Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I wouldn't recommend using javascript links as they don't work well for SEO.
     
    leebari, Oct 16, 2009 IP