如果页面包含网址字符串,则在运行时将其设置为超链接 [英] If page contains webaddress string then make it as hyperlink at runtime

查看:67
本文介绍了如果页面包含网址字符串,则在运行时将其设置为超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经创建了一个简单的HTML页面,

Hi,

I have created a simple HTML page,

<body>
	<p>www.google.com</p>
 
	<p>Page contents is here http://somelink.com</p>
</body>



运行此页面后, www.google.com和http://somelink.com 在表单上显示为简单文本.

我需要在运行时将它们转换为超链接....如
www.google.com
http://somelink.com

请为此指导我..

任何帮助将不胜感激..

在此先感谢



After running this page www.google.com and http://somelink.com appears as a simple text on form.

I need to convert them in hyperlink at runtime....as
www.google.com and
http://somelink.com

Please guide me for this..

any help would be grateful..

Thanks in advance

推荐答案

使用此脚本

use this script

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">


(document).ready(function(){
(document).ready(function() {


(" p).each(功能() { this.innerHTML =" code < a href = http://" + 此.innerHTML + " < /a > < /code > ; alert("ok"); }) }); < /script >
("p").each(function() { this.innerHTML = "<code><a href=http://" + this.innerHTML + ">" + this.innerHTML + "</a></code>"; alert("ok"); }) }); </script>


这篇关于如果页面包含网址字符串,则在运行时将其设置为超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆