Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Convert div tag to work as a link ???

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Convert div tag to work as a link ???

    Hi.

    Is it possible to have a div tag work as a link?
    Not just the text inside the tag but the whole tag.
    What I want to do is to have the following tag work as a link but I don't know how to do it in Dreamweaver.

    Div Tag
    Code:
    <div id="adobe">Here you can gratis download Adobe Reader which is necessary to open the files.</div>
    CSS
    Code:
    #adobe {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 11px;
    	font-weight: normal;
    	padding-left: 60px;
    	background-image: url(../images/adobe.gif);
    	background-repeat: no-repeat;
    	height: 40px;
    	padding-top: 11px;
    }
    Please someone give me a hint how to do this or maybe recommend a javascript if one is needed to achive this.

    Thanks in advance,
    Last edited by Cheng; 04-04-2008 at 10:42 AM.
    Cheng

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,880
    Thanks
    49
    Thanked 265 Times in 257 Posts
    Blog Entries
    56

    Default

    You mean something like(?):
    Code:
    <div href="javascript:void(0)" onclick="window.location.href='bla.html'"></div>
    Arie Molendijk

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Theres no point of the void :-/.
    Jeremy | jfein.net

  4. #4
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by molendijk View Post
    You mean something like(?):
    Code:
    <div href="javascript:void(0)" onclick="window.location.href='bla.html'"></div>
    Arie Molendijk
    .......yes, I thing something like this it is.
    It seems that without a javascript it cant be done.
    Can you link me to a script that I can use to do this...?...
    Cheng

  5. #5
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Cheng View Post
    .......yes, I thing something like this it is.
    It seems that without a javascript it cant be done.
    Can you link me to a script that I can use to do this...?...
    That's right. You'll need javascript for this.

    Technically, you can just insert a <div> within an anchor (<a>) element and it will work. However, it's not standards compliant markup.

    I'm not recommending it, just informing.

  6. #6
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......thanks for the replies.
    Can someone please point me to script that can be used.......
    Cheng

  7. #7
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    why cant you just have a long anchor tag?

    the div tag was created for layout purposes, not linking. What you want to do is an abuse of the div tag... similar to using tables as a layout schema.

    If you want an extended amount of text as a link, apply styles to an anchor tag.

  8. #8
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,880
    Thanks
    49
    Thanked 265 Times in 257 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by Nile View Post
    Theres no point of the void :-/.
    I've had several cases in which href="#" or something like that (href="javascript;", for instance) produced unwanted results. So I normally use href=javascript:void(0), which never let me down.
    You can do without the href, but then the link does not present itself as such.
    ----
    Arie M.

  9. #9
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boogyman View Post
    why cant you just have a long anchor tag?

    the div tag was created for layout purposes, not linking. What you want to do is an abuse of the div tag... similar to using tables as a layout schema.

    If you want an extended amount of text as a link, apply styles to an anchor tag.
    .......sorry, but I don't know how to do it using a long anchor tag.
    Could you give me an example please.......
    Cheng

  10. #10
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,880
    Thanks
    49
    Thanked 265 Times in 257 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by Cheng View Post
    .......sorry, but I don't know how to do it using a long anchor tag.
    Could you give me an example please.......
    Cheng, since you just want to have a link in a div for downloading Adobe Reader, you could do this, which opens a new window:
    Code:
    <div id="adobe" href="javascript:void(0)" onclick="window.open('bla.html')">Here you can gratis download Adobe Reader which is necessary to open the files</div>
    where 'bla.html' is the page you want to access. (That will probably a page with a download-link for Adobe).
    ----
    Arie.

Bookmarks

Posting Permissions

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