简体   繁体   English

将网站链接拆分为2 href链接?

[英]Split website link into 2 href link?

On my website public: http://abv.mk/company.aspx?id=40056 , i want to split http://www.donholding.com.mk & http://www.webklinika.mk to be separate links (and separate clickable like two different links - hrefs). 在我的公共网站上: http : //abv.mk/company.aspx? id= 40056 ,我想将http://www.donholding.com.mkhttp://www.webklinika.mk拆分为单独的链接(以及类似于两个不同链接的独立点击-hrefs)。

But in my admin-panel for the field website i only have 1 field available, where i input 2 web site links splited with "," 但是在现场网站的管理面板中,我只有1个可用的字段,在这里我输入2个网站链接,并用“,”分隔

So is it possible in the public asp-file "company.aspx", to edit the file and insert some Javascript code, so i split the link from 1 href to 2 hrefs ? 那么是否可以在公共asp文件“ company.aspx”中编辑该文件并插入一些Javascript代码,因此我将链接从1 href拆分为2 hrefs?

<span id="ctl00_ContentPlaceHolder1_lblComWeb"><a target="_blank" href="http://www.donholding.com.mk, www.webklinika.mk" title="">www.donholding.com.mk, www.webklinika.mk</a> | <a href="mailto:donholding@live.com" title="">donholding@live.com</a></span>

Viktor, as I could understand, this page only allows you to display one website. 据我所知,维克多(Viktor)仅允许您显示一个网站。

The href property of the a html tag only support reference to one address/page. href的财产a html标记只支持引用一个地址/页。

What you could do is put there the link to another page which is yours, and in this page you can put as many different links to anywhere you want and other information too. 您可以做的是在该页面上找到另一个页面的链接,并且在此页面中,您可以将许多不同的链接放置到您想要的任何地方,以及其他信息。 Maybe search for some URL shortener service which allows something like this. 也许搜索一些允许这样的URL缩短服务。

Now, if you actually do have access to the source code and modify it, all you have to do is: 现在,如果您确实有权访问和修改源代码,则要做的就是:

<span id="ctl00_ContentPlaceHolder1_lblComWeb">
    <a target="_blank" href="http://www.donholding.com.mk" >www.donholding.com.mk</a>, <a target="_blank" href="www.webklinika.mk" >www.webklinika.mk</a> | <a href="mailto:donholding@live.com" title="">donholding@live.com</a>
</span>

I'm guessing you have one field in the DB which stores the URL. 我猜您在数据库中有一个存储URL的字段。 This should probably instead be its own table - company_url, which takes company_id (in thie case, 40056) and the URL. 相反,它可能应该是它自己的表-company_url,它使用company_id(在这种情况下为40056)和URL。 You should bring back a DataSet, and create a HTML string to put in to the Literal (or whatever you're using). 您应该带回一个DataSet,并创建一个HTML字符串以放入Literal(或您使用的任何文件)中。

That's the "you should do this" answer. 那就是“你应该这样做”的答案。

Now.. you could do... 现在..你可以做...

$(document).ready(function(){
    var el = $('span[id$="lblComWeb"]');
    var el_a = el.children('a');
    links = el_a.html();
    links = links.split(',');
    el.html('');
    $.each(links,function(l){
        var e = '<a href="http://'+$.trim(links[l])+'" title="'+el.attr('title')+'" target="_blank">'+links[l]+'</a>'; 
        el.append((l > 0 ? ',' : '') + e); 
    });
});

as you're already using jQuery. 因为您已经在使用jQuery。 However, it's cheap and dirty and nasty and yucky. 但是,它便宜又脏又讨厌又讨厌。
Just putting that snippet in to your company.aspx file (between some tags) should do the trick. 只需将片段插入到您的company.aspx文件中(在某些标签之间)就可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM