在 JavaScript 中创建一个工具来插入超链接

Create a tool in javascript to insert a hyperlink

本文关键字:工具 一个 插入 超链接 JavaScript 创建      更新时间:2023-09-26

我需要在javascript中创建一个工具,以便于创建"

我需要的是这个:

1)单击"创建新链接"按钮>出现一个弹出窗口,其中包含如下文本输入:

" 请命名您要创建的链接(例如:链接到谷歌)"

2)单击"确定",出现第二个弹出窗口,其中包含第二个输入:

"请输入您要链接的网址(例如:www.google.fr)"

我很确定这种javascript已经存在了很多年,但我找不到这种代码的来源。有人知道答案吗?

function createNewLink(){
  var title = prmpt('please name the link you want to create (e.g : Link to Google)');
  var href = prompt('please insert the URL you want to link (e.g : www.google.fr) ');
  document.write('<a href="'+href+'">'+title+'</a>');
}