button inside href
Solution 1
No, this is not allowed according to the HTML5 specification.
-
The
<button>
element is considered "interactive content". -
The
<a>
element must contain "no interactive content".
The button will probably show up, but since you're violating the specification it may not behave as you want. You should avoid doing this.
The most reliable to way to make a button bring the user to a page is to create a <form>
that target
s that page, and make the button submit that form.
<form action="add-lead-new.php"><input type="submit" value="New Booking" /></form>
Solution 2
no, the button itself wont do anything - it's only usefull with javascript to trigger any functions. you should use css to make some of your links like a button: http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba
Solution 3
It's better to just use CSS, but if you're really stuck on using a physical button, you can create a dummy form with no data:
<form action="href"><input type="submit" value="Click Here" /></form>
Solution 4
<input type="button" value="New booking" onclick="self.frames['rightframe'].location.href='add-lead-new.php'"/>
would be ok
Comments
-
Phphelp almost 2 years
Is it ok to write like this?
<a href="add-lead-new.php" target="rightframe"><input type="button" value="New booking" /></a>
The link should look like a button but it should open in the right part of the page. If its wrong, is there any other way to do it? The above code works fine. i just don't know if its the correct way to do it. Thanks
-
Cystack almost 13 yearsYou might want to put an absolute URL though.
-
davecoulter almost 13 years+1 -- I agree, using css is a cleaner way to separate the concerns.
-
Cystack almost 13 yearsI had a typo first and corrected it... maybe try again ? it works for me
-
Cystack almost 13 years1st I would agree with people suggesting the CSS solution. 2nd I would heavily discourage the use of frames. But if you really want to use an <input>, then make sure that your 'rightframe' is created in HTML, make sure it has the name 'rightframe'. If it is just an iframe, my code will work. If it is a regular frame (ugly) then use top. instead of self.
-
Phphelp almost 13 yearsthe problem is i want the page to open in the right frame. in href i can write it as target="rightframe" but i don't know how to do that in button.
-
Jeremy almost 13 years@Phphelp Try
<form action="add-lead-new.php" target="rightframe">
. -
Phphelp almost 13 yearswell im working on a huge project. they have been developing it for 4 yrs.. i don't know much about it. there is already a link there. my boss wants it to be changed to a button. but it should open in the right frame.