Reply to Re: Create a link from an entry field

Your name:

Reply:


Posted by I V on 12/12/06 02:00

On Tue, 12 Dec 2006 00:28:06 +0000, Cogito wrote:
> Now guys, even if it is only academic, we can't let HTML beat us.
> There must be a way of transferring the entered URL to a link.

You could try this. I've only tested it on Firefox, so YMMV:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>URL transferer</title>
<script type="text/javascript">
var link, input;

function init()
{
link = document.getElementById('lnk');
input = document.getElementById('npt');
}

function make_link()
{
var anchor = document.createElement('a');
var caption = document.createTextNode(input.value);
anchor.href = input.value;
anchor.appendChild(caption);
while(link.firstChild)
link.removeChild(link.firstChild);
link.appendChild(anchor);
}

</script>
</head>
<body onload="init();">
<form>
<p>
<input type="text" id="npt">
<input type="button" value="Make link" onclick="make_link();">
</p>
<p id="lnk"></p>
</form>
</body>
</html>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация