Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2011, 07:08 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default Input text - Output Hyperlink

Hi,

Is it possible to output the same "text" as hyperlink?

Now, as you see, the word specified - >link< is displayed.

Would like to display the word(s) that is input'ed...possible???


<html>
<head>
<title>Links</title>
<script type="text/javascript">
function CreateLink() {
var str = '';
str += '<a href="http://'+document.getElementById('Text').value+'">link</a>';
document.getElementById('link').innerHTML = str;
}
</script>
</head>
<body>
<input type="text" id="Text" value="http://www." size="21">
<button onclick="CreateLink()">Convert</button>
<br>
<div id="link"></div>

</body>
</html>



Thanks
Jimp
 
Old March 10th, 2011, 03:30 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Did not think this was so tricky.....
 
Old March 10th, 2011, 04:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Maybe it's because your question isn't very clear?

Shouldn't you just concatenate document.getElementById('Text').value at the location of link as well, just as you do with the href part?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
JimP (March 10th, 2011)
 
Old March 10th, 2011, 05:39 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

That's great!

Thank you!



<html>
<head>
<title>Links</title>
<script type="text/javascript">
function CreateLink() {
var str = '';
str += '<a href="http://www.'+document.getElementById

('Text').value+'">'+document.getElementById('Text' ).value+'</a>';
document.getElementById('link').innerHTML = str;
}
</script>
</head>
<body>
<input type="text" id="Text" value="" size="21">
<button onclick="CreateLink()">Convert</button>
<br>
<div id="link"></div>

</body>
</html>
 
Old March 10th, 2011, 09:04 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

One more thing...

Is it very difficylt to display a screenshot of the url?


<html>
<head>
<title>Links</title>
<script type="text/javascript">
function CreateLink() {
var str = '';
str += '<a href="http://'+document.getElementById('Text').value+'">link</a>';
document.getElementById('link').innerHTML = str;
}
</script>
</head>
<body>
<input type="text" id="Text" value="http://www." size="21">
<button onclick="CreateLink()">Convert</button>
<br>
<div id="link"></div>

<img src="" alt="Img" />


</body>
</html>


Thanks...
 
Old March 10th, 2011, 09:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Creating a real screenhot can be pretty difficult and requires server side code: http://www.google.com/#sclient=psy&h...9cf98ce320b18f

However, you could load the URL in am <iframe> and display it locally...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
JimP (March 11th, 2011)
 
Old March 11th, 2011, 06:11 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Thanks Imar,

The iframe could be ok if there was a zoom properie, but its not.
(To se the hole site in a small 25px x 25px frame)

I like the other suggestion, I'll spend time on that...


Again, thanks...


Br
JimP





Similar Threads
Thread Thread Starter Forum Replies Last Post
Input javascript variable into hyperlink column toddw607 ASP.NET 2.0 Basics 1 April 17th, 2008 10:12 AM
XSLT with output very similar to input sindrit XSLT 2 July 30th, 2007 08:38 AM
Formating ListBox output to input into a file craigl Pro Visual Basic 2005 1 July 1st, 2007 08:02 AM
jsp - input/output - html?? tra77 JSP Basics 0 April 14th, 2006 04:35 AM
input:output file ct ASP.NET 1.0 and 1.1 Basics 1 September 27th, 2005 09:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.