我有一个非常具体的问题.我正在为手机写一个网页,上面有一个按钮.我正在检测touchevent包括IE在内的每个浏览器,但在IE上它是非常具体的.几秒钟后它会自动结束.你能以某种方式帮助我吗?这是我的代码(修改过的代码,但仍然无法正常工作):
if (window.navigator.pointerEnabled) {
tapButton.addEventListener("pointerup", function(e) {
e.preventDefault();
addClass(this, 'clicked');
buttonTouched = true;
}, false);
tapButton.addEventListener("pointerdown", function(e) {
e.preventDefault();
removeClass(this, 'clicked');
buttonTouched = false;
}, false);
alert("pointerEnabled");
}
else if (window.navigator.msPointerEnabled) {
tapButton.addEventListener("MSPointerDown", function(e) {
e.preventDefault();
addClass(this, 'clicked');
buttonTouched = true;
}, false);
tapButton.addEventListener("MSPointerUp", function(e) {
e.preventDefault();
removeClass(this, 'clicked');
buttonTouched = false;
}, false);
alert("mspointerEnabled");
}
else {
alert("ordinary touch");
tapButton.addEventListener('touchstart', function(e) {
e.preventDefault();
addClass(this, 'clicked');
buttonTouched = true;
}, false);
tapButton.addEventListener('touchend', function(e) {
e.preventDefault();
removeClass(this, 'clicked');
buttonTouched …Run Code Online (Sandbox Code Playgroud) 我是Tumblr的新手.我有这样的问题:
我正在使用Indy主题.当我发布几张照片时,点击它就像幻灯片一样,我的意思是它发布为{block:Photoset}.但是当我发布一张照片时,点击后,它会将我重定向到另一页.
我想要的只是让一张照片充当照片集并点击后显示在同一页面上.
提前到达.
这是主题的html的一部分:
{block:Photo}
<article class="post-photo" id="{PostID}">
<div class="post-content">
{block:IndexPage}<a href="{Permalink}"><img src="{PhotoURL-500}" data-highres="{PhotoURL-HighRes}" alt="{PhotoAlt}"></a>{/block:IndexPage}
{block:PermalinkPage}{LinkOpenTag}<img src="{PhotoURL-HighRes}" alt="{PhotoAlt}">{LinkCloseTag}{/block:PermalinkPage}
{block:Caption}<p>{Caption}</p>{/block:Caption}
{/block:Photo}
{block:Photoset}>
<article class="post-photoset" id="{PostID}">
<div class="post-content">
<div class="photo-slideshow" id="photoset_{PostID}" data-layout="{PhotosetLayout}">
{block:Photos}
<div class="photo-data">
<a rel="post-{PostID}" href="{PhotoURL-HighRes}" {block:Caption}title="{Caption}"{/block:Caption}>
<div class="pxu-photo">
<img alt="{PhotoAlt}" src="{PhotoURL-500}" width="{PhotoWidth-500}" height="{PhotoHeight-500}" data-highres="{PhotoURL-HighRes}" data-width="{PhotoWidth-HighRes}" data-height="{PhotoHeight-HighRes}">
</div>
</a>
</div>
{/block:Photos}
</div>
{block:Caption}<p>{Caption}</p>{/block:Caption}
{/block:Photoset}
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
function figureSelector () {
document.getElementById("rook").onclick = function () {
curr = '"rook"';
};
};
function moveLine(){
document.getElementById("upButton").onclick = function() {
document.getElementById(curr).style.top = document.getElementById(curr).offsetTop - getPix() * 62 + "px";
counter= counter + getPix();
};
Run Code Online (Sandbox Code Playgroud)
我想为棋子编写通用功能。我要的就是,当人们单击棋子,然后按向上按钮时,它必须上升。
我想覆盖AngularJS的电子邮件验证程序.我希望它使用我的自定义字符串来验证电子邮件地址.我在他们的文档中找到的代码是这样的:JS:
var app = angular.module('registrationApp', []);
app.directive('overwriteEmail', function() {
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@example\.com$/i;
return {
require: 'ngModel',
restrict: '',
link: function(scope, elm, attrs, ctrl) {
if (ctrl && ctrl.$validators.email) {
// this will overwrite the default Angular email validator
ctrl.$validators.email = function(modelValue) {
return ctrl.$isEmpty(modelValue) || EMAIL_REGEXP.test(modelValue);
}
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div data-ng-app="registrationApp" data-ng-init="">
<form name="form" class="css-form" novalidate>
<div>
Overwritten Email:
<input type="email" ng-model="myEmail" overwrite-email name="overwrittenEmail" />
<span ng-show="form.overwrittenEmail.$error.email">This email format is invalid! </span><br>
Model: {{myEmail}}
</div>
</form> …Run Code Online (Sandbox Code Playgroud) javascript html5 angularjs angularjs-directive angularjs-validation
我正在使用角度1.6.5进行角度应用,并且遇到了一种非常奇怪的行为.
我想要实现的是:当更改ngroute时,我必须从当前视图中删除活动类,等待完成离开动画,然后将活动类添加到新视图.
我在配置中设置了app和routs.
var app = angular.module('app', ['ngAnimate', 'ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl:"home.html",
reloadOnSearch:false
})
.when('/about-us', {
templateUrl:"about.html",
reloadOnSearch:false
})
.when('/contact', {
templateUrl:"contact.html",
reloadOnSearch:false
})
.otherwise({
template : "<h1>None</h1><p>Nothing has been selected</p>"
});
});
Run Code Online (Sandbox Code Playgroud)
我有一个服务,我存储动画时间和布尔指示视图的可见性:
app.service('animationProperties', function () {
this.animationTimings = {
views: 1000
};
this.visibility = {
view : false
};
});
Run Code Online (Sandbox Code Playgroud)
我有一个主控制器具有简单的调试功能和一个onRouteChangeStart函数,它应该从当前视图中删除活动类(通过使视图可见性布尔为false):
app.controller('MainCtrl', function ($scope, $window, $location,
animationProperties) {
$scope.animationProperties = animationProperties;
$scope.$on('$routeChangeStart',function () {
animationProperties.visibility.view = false;
});
$scope.toggleActive = function(){
$scope.animationProperties.visibility.view = !$scope.animationProperties.visibility.view; …Run Code Online (Sandbox Code Playgroud) 我一直在努力解决谷歌扩展的问题,而你一如既往是我最后的希望!:))
好吧,我想点击我的chrome扩展程序上的按钮,这将导致页面扩展程序上的keydown模拟正在运行.
我认为chrome在我的想法上有一些安全问题,它会阻止键盘模拟(使事件isTrusted:false)并删除哪个属性.
我写的函数在jsfiddle上运行正常,但看起来chrome扩展以不同的方式完成它.
这是内容脚本文件:
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if(request.action == "scrollToTop"){
}
else if(request.action == "scrollToBottom"){
}
else if(request.action == "enter"){
triggerKeyboardEvent(document,13);
}
function triggerKeyboardEvent(el, keyCode){
var event = new Event("keydown", {"bubbles":true, "cancelable":true});
event.which = keyCode;
el.dispatchEvent(event);
}
});
chrome.runtime.sendMessage({action : "show"});
Run Code Online (Sandbox Code Playgroud)
登录jsFiddle写道:
Event {isTrusted: false, which: 13}
Run Code Online (Sandbox Code Playgroud)
登录网站:
document.addEventListener('keydown',function (e) {
console.log(e)
}
Run Code Online (Sandbox Code Playgroud)
写道:
Event {isTrusted: false}
Run Code Online (Sandbox Code Playgroud) javascript ×5
angularjs ×2
html ×2
css ×1
html5 ×1
jquery ×1
ng-animate ×1
ng-view ×1
touchstart ×1
tumblr ×1
web ×1