我正在使用bit.ly url缩短服务来缩短某些网址被发送到"在twitter上分享"功能.我只想在用户实际按下共享按钮时加载bit.ly url(由于bit.ly的max 5 parallel reqs限制).Bit.ly的REST API使用缩短的url返回JSON回调,这使整个场景异步.
我已尝试以下方法来停止click事件,并等待JSON调用在启动单击之前返回一个值.
我在jQuery(document).ready()中有以下简化代码:
更新的代码(过度简化)!
jQuery("#idofaelement").click(function(event) {
event.preventDefault(); //stop the click action
var link = jQuery(this);
bitlyJSON(function(shortUrl) {
link.attr("href", function() {
//process shortUrl
//return finalized url;
}).unbind().click();
});
});
Run Code Online (Sandbox Code Playgroud)
并使用以下代码来处理缩短的缩短(工作得很好):
function bitlyJSON(func) {
//
// build apiUrl here
//
jQuery.getJSON(apiUrl, function(data) {
jQuery.each(data, function(i, entry) {
if (i == "errorCode") {
if (entry != "0") {
func(longUrl);}
} else if (i == "results") {
func(entry[longUrl].shortUrl);}
});
});
} (jQuery)
Run Code Online (Sandbox Code Playgroud)
href的值已更改,但最终的.click()事件永远不会被触发.这在为href定义静态值时工作正常,但在使用异步JSON方法时则不行.
<%= will_paginate(@posts) %>
# will generate the links like this '<a href="/posts?page=n">a link</a>'
Run Code Online (Sandbox Code Playgroud)
如果我想更改href基础等/contents,我该怎么办<a href="/contents?page=n">a link</a>?
似乎没有选择,帮助!
有谁知道为什么它不起作用?
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
<script>
$('#main').click(function() {
alert('foobar');
document.location.href='02.html';
});
</script>
<style type="text/css">
body {margin:0px; background:#f2f2f2;}
#main {background:url(01.jpg) top center no-repeat; height:1745px; width:100%; text- align:center; overflow-x:hidden; cursor:pointer; cursor:hand;}
</style>
</head>
<body>
<div id="main"></div>
</body>
Run Code Online (Sandbox Code Playgroud)
请帮助
我试图找出一个href attr是空的做什么,我的代码如下...
jQuery('#sidebar a').click(function() {
var bob = jQuery(this).attr("href");
if(jQuery(bob).attr() == "") {
alert('I am empty href value');
}
});
Run Code Online (Sandbox Code Playgroud)
我不知道我哪里出错了?有什么建议?谢谢!
所以,我正在开发一个具有jquery onClick功能的网站.嗯,链接很简单href="#".
好吧,每次点击,
有没有更好的选择,或者我做错了什么?
我该怎么写行:
<a href="User?id=<c:out value="${user.id}" />" >Profile</a>
Run Code Online (Sandbox Code Playgroud)
是否正确?它应该给我一些像个人资料
我的背景:
<c:forEach items="${requestScope.users}" var="user">
<tr>
<td><c:out value="${user.login}" /></td>
<td><c:out value="${user.name}" /></td>
<td><c:out value="${user.lastname}" /></td>
<td><a href="User?id=<c:out value="${user.id}" />" >Profile</a></td>
</tr>
</c:forEach>
Run Code Online (Sandbox Code Playgroud) 是否可以从具有已定义消息的网页在Microsoft Lync上打开IM窗口?就像是:
<a href="im:?body=My Message">Lync</a>
Run Code Online (Sandbox Code Playgroud)
等效的电子邮件将是:
<a href="mailto:?body=My Message">E-Mail</a>
Run Code Online (Sandbox Code Playgroud) 以下脚本的目的是什么?
<head>
<script>document.write('<base href="' + document.location + '" />');</script>
...
</head>
Run Code Online (Sandbox Code Playgroud)
我有点明白,base href用于设置默认路径的初始部分.那么这个网址在哪里设置?后来我正在使用
<body ng-app="plunker" ng-controller="NavCtrl">
<p>Click one of the following choices.</p>
<ul>
<li ng-class="{active: isActive('/tab1')}"><a href="#/tab1">tab 1</a></li>
<li ng-class="{active: isActive('/tab2')}"><a href="#/tab2">tab 2</a></li>
</ul>
<pre>{{ path }}</pre>
</body>
Run Code Online (Sandbox Code Playgroud)
使用以下控制器:
var app = angular.module('plunker', []);
app.controller('NavCtrl', function($scope, $location) {
$scope.isActive = function(route) {
$scope.path = $location.path();
return $location.path() === route;
};
});
Run Code Online (Sandbox Code Playgroud) 现在我正在尝试在list-group-item中插入glyphicon或按钮.我想要的是,当用户点击list-group-item中的任何位置时,它们会链接到某个页面,但是当他们单击glyphicon或按钮时,它们会链接到另一个页面.为什么我尝试这样做,它继续将glyphicon或按钮放在list-group-items框之外.为什么是这样?我怎样才能解决这个问题?
非常感激.
码:
<div class="list-group">
<a href="my_django_url" class="list-group-item">
<a href="another_django_url"><span class="glyphicon some-glyphicon"></span></a>
</a>
Run Code Online (Sandbox Code Playgroud)
在JavaDoc中,我可以将超链接表示为@see <a href="http://google.com">http://google.com</a>。在科特林如何做到这一点?
href ×10
jquery ×4
html ×2
javascript ×2
angularjs ×1
attr ×1
bit.ly ×1
glyphicons ×1
hash ×1
hyperlink ×1
if-statement ×1
json ×1
jsp ×1
jstl ×1
kdoc ×1
kotlin ×1
lync ×1
lync-2013 ×1
ruby ×1
url-scheme ×1