Jump to content

make <div> behave like <a> tag?


adredz

Recommended Posts

i have a div that has a onclick attribute. the problem is i can't right-click(to open to a new tab) on it and it won't display the target link on the browser's status bar. i know i can insert a <a> tag, but it requires a text for the link and it would make things complicated for me since i already have the background image of my div marked with text. any help?

Link to comment
Share on other sites

It's bad practice to use javascript for opening links, as users without javascript turned on will not be able to use the link.

 

Change the div to an <a> tag, and apply your background to that. It will fix all your problems, including the ones you didn't realize you have.

Link to comment
Share on other sites

  • 3 weeks later...

i have a div that has a onclick attribute. the problem is i can't right-click(to open to a new tab) on it and it won't display the target link on the browser's status bar. i know i can insert a <a> tag, but it requires a text for the link and it would make things complicated for me since i already have the background image of my div marked with text. any help?

 

You can wrap the div in an ancher tag, this would allow it to be clicked, and rightclicked accordingly (as long as it's in the div itself and not in interelements)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.