我的html文件中有相同的ancors/hyperlink.这些指向我网站外的新网站.所以我希望当用户点击链接时,它应该打开一个新的选项卡或窗口.我的网站页面不应该关闭.
怎么做到呢?
我有一个像元素列表
<ol>
<li class="blah">some text <a href=#">test</a></li>
<li class="blah">some text <a href=#">test</a></li>
<li class="blah">some text <a href=#">test</a></li>
<li class="blah">some text <a href=#">test</a></li>
<li class="blah">some text <a href=#">test</a></li>
<li class="blah">some text <a href=#">test</a></li>
<li class="blah">some text <a href=#">test</a></li>
<ol>
Run Code Online (Sandbox Code Playgroud)
我想添加一个悬停元素,这样当用户将鼠标悬停在<li>上时,只有那些项<a>悬停.
我有这个(启用悬停的只是一种颜色)
jQuery('ol li').hover(function () {
jQuery('ol li.blah a').addClass('hover-enabled');
}, function () {
jQuery('ol li.blah a').removeClass('hover-enabled');
});
Run Code Online (Sandbox Code Playgroud)
它可以工作,但所有<a>项目都悬停 - 而不仅仅是个人<li>.有任何想法吗 ?
我正在尝试在about框中添加一个Twitter个人资料的链接."常规"链接(如电子邮件地址和网址)由处理
android:autoLink="email|web"
Run Code Online (Sandbox Code Playgroud)
在about.xml中,但对于Twitter个人资料页面,我需要在strings.xml中使用html代码.我试过了:
<string name="twitter">Follow us on <a href=\"http://www.twitter.com/mytwitterprofile">Twitter: @mytwitterprofile</a></string>
Run Code Online (Sandbox Code Playgroud)
在about框上呈现html标记.
我也尝试过:
<string name="twitter">Follow us on <a href="http://www.twitter.com/mytwitterprofile">Twitter: @mytwitterprofile</a></string>
Run Code Online (Sandbox Code Playgroud)
它显示文本"在Twitter上关注我们:@mytwitterprofile",但它不是超链接.
我该怎么做这个看似简单的任务!?
干杯,巴里
我在处理比我的根文件夹更高级别的文档时遇到了麻烦.
<a href='../../home/folder/document.docx'>Proposal</a>
Run Code Online (Sandbox Code Playgroud)
在浏览器中,上面的内容被解释为:
http://localhost/home/folder/document.docx
Run Code Online (Sandbox Code Playgroud)
我看不到浏览器在文件夹中出现,然后我得到的答案是:
Not Found
The requested URL /home/folder/document.docx was not found on this server.
Run Code Online (Sandbox Code Playgroud)
我在Firefox和Chrome上试过,它也是一样的.我在Linux机器上使用Apache Web Server.
任何帮助将不胜感激.
我想创建一个菜单,当鼠标悬停和onclick时会改变.
但是,点击时我的onclick只会变成空白.
我发现如果我删除了一个href,onclick函数将起作用.
有谁知道如何解决这个问题?
<a href="{storeurl}?act=aboutus">
<img src="skins/sunlift/styleImages/navbar_pic/aboutus_n.jpg"
onclick="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_h.jpg'"
onmouseover="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_h.jpg'"
onmouseout="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_n.jpg'"/>
</a>
Run Code Online (Sandbox Code Playgroud) 我有以下代码将添加target="_blank"到所有链接:
$(function() {
$("a[href^='http://']").attr("target","_blank");
});
Run Code Online (Sandbox Code Playgroud)
如何重新编写上述代码以定位除内部链接之外的所有链接.
IE:
http://www.my-site.com/ =内部链接
http://www.other-site.com/ =外部链接
另外,我如何定位任何不以http://内部开头但不在内部的链接?
我正在寻找一个jQuery解决方案.
以下是我的锚标记的HTML代码:
<a delhref="http://localhost/eprime/entprm/web/control/modules/questions/manage_question_issue.php?op=fixed&question_id=21627&que_issue_status=0" title="Fixed" href="#fixedPopContent" class="fixed">Fixed</a>
Run Code Online (Sandbox Code Playgroud)
现在我想在上面的锚标记中添加一个问题id,并在用户点击这个超链接时在jQuery中访问它.对于它我尝试下面的代码,但它没有为我工作.
<a delhref="http://localhost/eprime/entprm/web/control/modules/questions/manage_question_issue.php?op=fixed&question_id=21627&que_issue_status=0" title="Fixed" href="#fixedPopContent" class="fixed" data="21627">Fixed</a>
Run Code Online (Sandbox Code Playgroud)
它的jQuery代码如下:
$(document).ready(function() {
$(".fixed").click(function(e) {
var t2 = $(this).data();
alert(t2);
});
});
Run Code Online (Sandbox Code Playgroud)
它在警告框中给我消息[对象对象].任何人都可以帮助我将值设置为锚标记并在jQuery中访问它?
我有这行代码.我试图将我的链接指向谷歌进行测试.
$content.="<a href='google.com' target=_blank>".$webSites['value']."</a>";
Run Code Online (Sandbox Code Playgroud)
我没有获得"google.com",而是按照以下方式获得:(http://192.168.10.126/consumer/google.com).
我使用以下命令定位包含jQuery中各种文件类型的链接:
jQuery('a[href$=".pdf"], a[href$=".doc"], a[href$=".docx"], a[href$=".ppt"], a[href$=".pptx"], a[href$=".xls"], a[href$=".slxs"], a[href$=".epub"], a[href$=".odp"], a[href$=".ods"], a[href$=".txt"], a[href$=".rtf"]').before('<span class="glyphicon glyphicon-file"></span> ');
Run Code Online (Sandbox Code Playgroud)
首先,有没有办法减少重复?例如
jQuery('a[href$=".pdf|.doc|.docx"])
Run Code Online (Sandbox Code Playgroud)
其次,有没有办法针对文件扩展名针对不同的情况,例如Pdf,PDF和pdf?
所以我写了这个小应用程序,在其中显示了从Wikipedia获取的一些信息。此提取的HTML内也有链接。
所以我想做的是:
每次用户单击链接时,我都想拦截该链接并执行自定义行为,而不是默认的浏览器重定向。
Angular httpinterceptor中的构建在这里不起作用。我如何获得这种效果?
编辑:似乎我误解了href和http请求的工作方式。我仍然想对应用程序上单击的每个链接进行自定义行为。有没有办法拦截那些“事件”?
编辑:对于Angular 2+解决方案,请看下面我的答案。它是一种拦截标签的服务。