【发布时间】:2018-05-17 11:37:13
【问题描述】:
我有一个在网络浏览器中本地运行的 html 页面,并且在代码中我有一系列链接。链接包裹在按钮周围,并且按钮使用 CSS 设置样式。我经常需要添加链接,所以我想直接在页面上放置一个“新链接创建者”,并根据输入框中的 url 创建一个按钮。以下是一些链接和它们周围的代码:
<div class='m'>
<a href='https://stackoverflow.com/' target='_blank'><input type='button' class='menu' value='Stack Overflow'></a>
<a href='https://puzzling.stackexchange.com/' target='_blank'><input type='button' class='menu' value='Puzzling Stack Exchange'></a>
<a href='https://pastebin.com/' target='_blank'><input type='button' class='menu' value='Pastebin'></a>
<a href='https://github.com/' target='_blank'><input type='button' class='menu' value='GitHub'></a>
<a href='https://scholar.google.com/' target='_blank'><input type='button' class='menu' value='Google Scholar'></a>
<a href='https://google.com/' target='_blank'><input type='button' class='menu' value='Google'></a>
<a href='https://encrypted.google.com/' target='_blank'><input type='button' class='menu' value='Encrypted Google'></a>
</div>
这是我迄今为止在解决问题方面取得的进展(基本上没有):
<div class='tb'>
<input type='text' id='get_url'></input>
<input type='button' value='Create New Button' onclick='newbutton();'></input>
</div>
哪个指向这个JS:
function newbutton() {
var url = document.getElementById('get_url');
// ... make button with the given url
}
感谢任何帮助。如果我需要包含更多代码(例如我的 CSS),请在 cmets 中告诉我。
【问题讨论】:
-
你可以这样做,一旦你刷新页面它就会消失
-
我知道,没关系 - 我不希望它们成为永久性的。
标签: javascript html