-1

I have a JS function that creates a new popup window.

function newTab(center, section, tab) {
    currentItem.numWindows += 1;
    var title = "Window #" + currentItem.numWindows;
    var tabsObject = [center, section, tab];
    currentItem.windows[currentItem.numWindows] = window.open('popup.php', title, toolbar = 0, menubar = 0, navigationbar = 0);
    currentItem.windows[currentItem.numWindows].variable = tabsObject;
}

I want to create a button that looks like a button but acts like a link. To clarify, when the user right clicks on the button I need it to open up the standard browser options like "open in new window" or "open in new tab".

Instead of this leading to a standard "otherpage.html" I need it to call my JS function (which in turn creates the popup).

I have searched and I keep finding examples that look like a link but don't act like a link.

I have tried IameLemon's suggestion,

<a onclick="someFunction();"><button type="button">Text of Some Page</button></a>

this code works however it does not allow the user to right click and access the standard options that come with a link (the ability to open in a new tab or window)

Thanks!

4 Answers4

0

Apply css styling to an anchor.

<a href='function();' style='whateverfloatsYourBoat'>value</a>
0

make a button within a link:

<a href='newtab();'><button type=button>button text</button></a>
pppp
  • 231
  • 1
  • 11
0

Stealing from another answer.

Why not just wrap a button in a link? Here's a fiddle as well.

<a onclick="someFunction();"><button type="button">Text of Some Page</button></a>
Community
  • 1
  • 1
Steven B.
  • 8,962
  • 3
  • 24
  • 45
-1
Use CSS. Below will make a link look like a button. i.e., if you right click it, it will give you option to open in new tab, etc.

.SSSBUTTON_CONFIRMLINK {
    font-family: Arial,sans-serif;
    font-size: 11px;
    font-weight: normal;
    font-style: normal;
    font-variant: small-caps;
    color: rgb(64, 111, 53);
    background-color: rgb(222,235,181);
    letter-spacing: 1px;
    text-decoration: none;
    text-transform: capitalize;
    text-align: center;
    line-height: 20px;
    margin-left: 1px;
    border-width: 1px;
    border-top-color: rgb(142, 203, 98);
    border-bottom-color: rgb(114, 175, 69);
    border-left-color: rgb(142, 203, 98);
    border-right-color: rgb(114, 175, 69);
    border-top-style: none;
    border-bottom-style: solid;
    border-left-style: none;
    border-right-style: solid;
    height: 20px;
    white-space: nowrap;
    cursor: pointer;
}

<a class="SSSBUTTON_CONFIRMLINK" href="#top">Click Me</a>
Paul
  • 652
  • 5
  • 16