|
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>
Navigation:
[Reply to this message]
|