php href里面的按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6783788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:14:05  来源:igfitidea点击:

button inside href

phphtmlbuttonhref

提问by Phphelp

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

该链接应该看起来像一个按钮,但它应该在页面的右侧打开。如果错了,有没有其他方法可以做到?上面的代码工作正常。我只是不知道这是否是正确的方法。谢谢

回答by Facebook Staff are Complicit

No, this is not allowed according to the HTML5 specification.

不,根据HTML5 规范,这是不允许的。

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 targets that page, and make the button submit that form.

最可靠的方法,使一个按钮将用户带到一个页面是创建<form>targets表示页面,并且使按钮提交该表格。

<form action="add-lead-new.php"><input type="submit" value="New Booking" /></form>

回答by iHaveacomputer

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

不,按钮本身不会做任何事情——它只是用 javascript 来触发任何功能。你应该使用 css 来制作一些像按钮一样的链接:http: //www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba

回答by RétroX

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:

最好只使用 CSS,但如果你真的坚持使用物理按钮,你可以创建一个没有数据的虚拟表单:

<form action="href"><input type="submit" value="Click Here" /></form>

回答by Cystack

<input type="button" value="New booking" onclick="self.frames['rightframe'].location.href='add-lead-new.php'"/>

<input type="button" value="New booking" onclick="self.frames['rightframe'].location.href='add-lead-new.php'"/>

would be ok

没问题

回答by u283863

Yours is working but this is better,

你的正在工作,但这更好,

<input type="button" value="New booking" onClick="top.frames['rightframe'].src='add-lead-new.php'" />

回答by JefWit1F

This is what worked for me.

这对我有用。

<a><?php echo( "<button onclick= \"location.href='inc/name_of_php_file.php'\">your buttons name goes here</button>");?></a>

In other words nest your desired php code block inside an anchor element to 'link' it. Then add the php code block and inside that code block you'll want to add an echo(). Inside that echo you want to add your HTML code like normal. As if you weren't even writing in PHP.

换句话说,将所需的 php 代码块嵌套在锚元素中以“链接”它。然后添加 php 代码块,并在该代码块中添加一个 echo()。在该回声中,您想像往常一样添加 HTML 代码。就好像您甚至不是用 PHP 编写一样。

Edit the folder name and file to your desired location. And then finally edit what text you want your button to show your viewers.

将文件夹名称和文件编辑到所需位置。然后最后编辑您希望按钮向观众显示的文本。

onclick= \"location.href='folder_name_goes_here/name_of_php_file_goes_here.php'\">your buttons name goes here

onclick= \"location.href= 'folder_name_goes_here/name_of_php_file_goes_here.php'\">你的按钮名称在这里

This should link to your page with your desired caption.

这应该链接到您的页面,并带有您想要的标题。

Please keep in mind the \"as this is utterly important. Without \ in front of the " your code wont read correctly due to the many "s found nested inside each other. \ allows HTML to ignore the first " as an end to the echo Sting.

请记住\",因为这非常重要。如果没有 \ 在 " 前面,您的代码将无法正确读取,因为许多 " 相互嵌套。\ 允许 HTML 忽略第一个 " 作为结束回声斯汀。