js鼠标滑轮缩放图片屏蔽滚动条

在做一个鼠标滑轮缩放图片,滚动滑轮浏览器的滚动条一起滚动,经过一番折腾,终于解决了,贴出来给有有需要的人参考下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
</body>

<script>
var n=1;
function pingbi(e){
if (e&&e.preventDefault) { // Firefox
e.preventDefault();
e.stopPropagation();
} else { // IE
window.event.returnvalue=false

// window.event.keyCode = -1;
return false;
}
}
function xiufu(e){
if (e&&e.preventDefault) { // Firefox
e.preventDefault();
e.stopPropagation();
} else { // IE
window.event.returnvalue=true;

// window.event.keyCode = -1;
return true;
}
}
function mwEvent(e)
{
pingbi(e);
if (!e) e = window.event;
//alert(e.keyCode);
//if(e.preventDefault)e.preventDefault();
//else e.returnvalue=false;
//alert(e.keyCode);

if ( e.wheelDelta <= 0 || e.detail > 0) {
if(n<3)
n+=0.1;
}
else {
if(n>1)
n-=0.1;
}
img(n);
window.status=n;
document.getElementById("show").innerHTML=n;


}
function pbie(){
document.onmousewheel= pingbi;
}
function xfie(){
document.onmousewheel= xiufu;
}
var width,height;
function img(n){
document.getElementById("test").width=width*n;
document.getElementById("test").height=height*n;
}
//if(document.attachEvent){
//document.attachEvent("onmousewheel",mwEvent);
//}else{
//window.addEventListener("DOMMouseScroll", mwEvent, false);
//}
//window.onscroll=function(e){alert(window.event.keyCode);};


function init(){

var tt=document.getElementById("test");
tt.onmouseover=pbie;
tt.onmouseout=xfie;
if(tt.attachEvent){
tt.attachEvent("onmousewheel",mwEvent);
}else{
tt.addEventListener("DOMMouseScroll", mwEvent, false);
}
width =document.getElementById("test").width;
height=document.getElementById("test").height;
}
</script>
<body onLoad="init()">
<p>只有第一张图片会缩放,并解决ie下滑轮滚动滚动条一起滚动的问题</p>
<div style="position:relative;height:400px;width:400px;overflow:hidden;border:2px solid #ccf;">
<img src="te2.jpg" id="test" width="350" height="350"/><br/>
</div>
<img src="test.jpg" width="350" height="350"/><br/>
<img src="test.jpg" width="350" height="350"/><br/>
<img src="test.jpg" width="350" height="350"/><br/>
<div id="show">----</div>
</body>
</html>
两路半桥LLC谐振变换器软开关Simulink仿真(模拟谐振参数不同、分裂电容) 内容概要:本文介绍了“两路半桥LLC谐振变换器软开关Simulink仿真”资源包,重点在于基于Simulink平台对两路半桥LLC谐振变换器进行高精度建模与动态仿真,特别考虑了谐振参数不一致及分裂电容等非理想工况对系统性能的影响。该仿真模型不仅涵盖了主电路拓扑、软开关实现机制与谐振网络设计,还深入分析了不同参数配置下系统的启动特性、稳态效率、动态响应及软开关条件的满足情况。通过参数扫描与对比仿真,帮助用户掌握LLC变换器的关键设计要素与优化方法,具备较强的工程指导价值和科研教学意义。; 适合人群:电力电子、电气工程及其自动化等相关专业的高校师生,以及从事高频开关电源、新能源变换器、车载充电机等领域的研发工程师和技术人员。; 使用场景及目标:① 掌握两路并联半桥LLC谐振变换器的建模与仿真方法;② 理解软开关技术在提升变换器效率与降低EMI方面的关键作用;③ 分析谐振参数偏差与分裂电容结构对系统均流特性、增益曲线及软开关范围的影响;④ 支持科研项目中的拓扑验证、控制策略开发与故障工况分析; 阅读建议:建议结合Simulink仿真模型与配套说明文档进行学习,重点关注谐振腔参数设置、驱动时序设计及软开关波形观测;可通过调整谐振电感、电容值或引入参数失配,观察系统行为变化,深入理解LLC变换器的稳定边界与优化设计原则。 立即下载

相关推荐

MEMS惯性传感器关键参数解析与误差优化策略

本文深入解析了MEMS惯性传感器的关键性能参数,如零偏稳定性、噪声与随机游走、振动整流误差等,并阐述了这些误差如何导致设备导航漂移、姿态不稳等问题。文章重点探讨了从硬件选型、系统设计到校准补偿、算法融合(如卡尔曼滤波)以及温度补偿等实战优化策略,旨在帮助工程师有效提升自动驾驶、无人机等设备的测量精度与稳定性。

weixin_28363123的博客 415

js实现鼠标滚轮放大缩小页面指定区域(css3 scale)

js实现鼠标滚轮放大缩小页面指定区域(css3 scale)

slom_fxt的博客 1612

【AI实战】用Coze工作流打造抖音视频文案提取神器——从单链接到批量处理的进阶指南

本文详细介绍了如何利用Coze工作流打造抖音视频文案提取工具,从单链接处理到批量提取的进阶指南。通过AI技术和工作流的结合,用户可以高效提取抖音视频的ASR和OCR文本,大幅提升内容创作效率。文章还涵盖了性能优化、异常处理及实际应用场景扩展,助力开发者快速实现抖音文案自动化提取。

weixin_29210759的博客 281

完美解决js 禁止滚动条滚动,并且滚动条不消失,页面大小不闪动

当前的项目遇到了这个问题, 当打开dialog的时候,希望主页面的滚动条不要滚动。 一番搜索之后,发现大家的解决办法分为两种。 第一种 就是隐藏滚动条,但是这样的话,前台页面会因为滚动条的隐藏和出现而发生宽度的变化。 这就使得每次一打开dialog页面就会伸缩。十分难受。 第二种 就是不知道从哪儿抄的这种方法。 //禁止滚动条滚动 function unScroll() { var top = $(document).scrollTop(); $(document).

q564240849的博客 7576

从数据校准到论文呈现:fsQCA与NCA方法融合的完整实证研究指南

本文详细介绍了fsQCA(模糊集定性比较分析)与NCA(必要条件分析)方法融合的完整实证研究流程,从数据校准到论文呈现。通过软件操作技巧、R语言NCA包高效使用及论文写作规范,帮助研究者避免常见误区,提升研究质量与可靠性。特别适合需要进行组态分析的研究生和学者参考。

weixin_29215391的博客 420

【张量分解(二)】CP分解

一、CP分解 1.1 定义 CP分解就是将一个张量分解成多个单秩张量的和。例如,给定一个三阶张量X∈RI×J×K\mathcal{X}\in\mathbb{R}^{I\times J\times K}X∈RI×J×K,则CP分解可以写为 X≈∑r=1Rar∘br∘cr\mathcal{X}\approx\sum_{r=1}^{R}\textbf{a}_r\circ\textbf{b}_r\circ...

bqw的博客 2万+

js禁止鼠标滚轮缩放大小

document.addEventListener('keydown', function (event) { if ((event.ctrlKey === true || event.metaKey === true) && (event.which === 61 || event.which === 107 || event.which === 173 || ev...

qq_41818857的博客 1400

WiFi信道状态信息 基于Intel 5300的CSI Tool 安装及使用(一)

经过半个月的坎坷安装过程,连Windows系统都没装过的本人终于颤颤巍巍把CSI TOOL装好了,下面记录一下适于我所使用设备的安装过程。设备:一台THINKPAD X201,一台师兄借的华硕主板的台式机首先,如果你和我一样对linux其实一窍不通的话,建议先反复看教程里的安装代码,照猫画虎很难一步实现的,中途一定会有这或那的问题需要解决,所以该了解的基础linux指令还是要了解,起码安装过程中的那些指令可以去查一查。.........

Silver_777的博客 2万+

原生javascript鼠标滚轮滚动放大缩小效果

&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp

CodingNoob 6257

STM32G070xx将Flash页分块方式存储,固定数据块存储,实现一次擦除多次写入

本例程使用STM32G070xx芯片,Flash大小128KB,Flash每页(2048字节)写满后再擦除。操作存储区分为64块,每块32字节,即写满64次擦除一次;标定存储区分为16块,每块128字节,即写满16次擦除一次,每个存储区的块都有各自的头部标记

RaphaelCeo的博客 1549

从0开始,部署micro_ros+stm32f407+stm32cubeIDE

(5)安装依赖项rosdep时,必须处于创建的microros_ws中,因为里面有clone的src文件夹。(3)教程a中的安装docker不是必须的,取决于运行agent时是否想使用docker。(4)记得安装rosdep,并在以后的命令中将rosdep替换为rosdepc。4、运行agent,选择udp、tcp、can、串口,这里没有使用docker。(1)首先参考教程a安装虚拟机和ubuntu,注意版本选择22.04;(2)参考教程b部署micro_ros构建系统。二、安装和运行agent。

m0_37963053的博客 2236

JavaScript如何在使用鼠标滚轮时禁止滚动页面

如何在使用鼠标滚轮时禁止滚动页面 使用element.onmousewheel在触发的函数里return false就可以鼠标滚动滚轮时不滚动页面,return true则会开启鼠标滚轮滚动页面 这里的onmousewheel不能被addEventListener('mousewheel',funtion(){return false})所代替,不然会没有效果 //return false禁用鼠标滚动页面 window.onmousewheel=function(){ return false }

qq_20512783的博客 8488

YOLOv8改进策略【Neck】| BiFPN:双向特征金字塔网络-跨尺度连接和加权特征融合

可扩展的高效物体检测BiFPN(加权双向特征金字塔网络)

Limiiiing的博客 1082

通过鼠标滚轮放大 缩小图片,同时防止滚轮事件 影响body的滚动条

方案 1:当鼠标移入 div 时,设置 body 的 overflow 为 hidden,移出时候,设置 overflo 为 auto。放大缩小图片很简单,但是当我移动滚轮的时候,发现滚轮的事件冒泡出去了。最终做到了当鼠标移到图片上时,仅放大 缩小图片,不触发外部的滚动条。body 中某个 div 滚动,防止冒泡到 body 滚动。上篇文章中,我最里层的图片 要支持鼠标滚轮 放大缩小图片。自动触发了body或者div的滚动条,页面晃动个不停。同时放一篇文章 博主解决的我的麻烦(留着以后备查)…

weixin_43627719的博客 601

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

js 以鼠标滚轮位置为中心缩放、放大以及边界判断

项目需求为页面上实现拖拽节点和可以在页面中通过滑动滚轮来缩放节点显示(以鼠标位置为缩放中心点)从而放大到可以看到详细的信息,节点有10000个。特此记录下实现细节。

qq_44001572的博客 4105

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

重写鼠标滚轮事件阻止滚动条冒泡

遇到一个问题,页面和子页面同时存在滚动条,在鼠标滚轮时候,会冲突:子页滚动条到顶部或者底部时候会继续冒泡,去滚动父节点的滚动条。 解决这个问题,必需要拦截鼠标滚轮事件,重写滚动事件,这时候又出现了烦人的浏览器兼容问题: 1、不同浏览器标滚轮事件不一样:FF下是DOMMouseScroll,其它onmousewheel。 2、事件阻止方式不一样:FF只支持e.preventDefault(),

技术人 3661

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

JS实现点击图片放大鼠标可拖动

功能点:点击图片放大,滚动鼠标滚轮可再次放大缩小,鼠标点击可拖动图片位置 使用方法: js已经封装好了,只要在将选择器筛选之后的对象当作参数传入方法中即可: js调用: 加载完页面之后绑定下事件: //$(".kc-media-div p img:not([name='messageName'])")是要实现此功能测图片对象(防止有些视频对象也用img标签) imgZoom($(".k...

SELECT_BIN的博客 2246

前端页面实现鼠标滚动缩放图片,鼠标左键拖拽图片,div内部禁止页面滚动

前端页面实现鼠标滚动缩放图片,鼠标左键拖拽图片,div内部禁止页面滚动

debugtoday的博客 1298

js实现鼠标滚轮图片放大缩小

<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document</title> </head> <body> <img id="img" src="11.png" alt="" style="width:100p

qq_45785424的博客 6542

js指定内容滚动左侧或其它地方不滚动

代码如下: $(document).ready(function(){ var obj = $('.e-left'); var offset = obj.offset(); var topOffset = offset.top; var leftOffset = offset.left; var marginTop = obj.css("marginTop"); var

十三狼的专栏 782

js滚轮控制图片的放大缩小

1、添加一张图片 id="chgImg" src="1.jpg" width="760" onmousewheel="return bigimg(this)" style="cursor:pointer" /> 2、 function bigimg(obj){ //alert(parseInt(obj.style.zoom,10)); var zoom =

luckydie的博客 1万+

jquery 地图缩放时禁止父容器滚动条滚动

/** * 控制滚动条 */ $(function(){ if (document.mozFullScreen !== undefined) { var scrollEventType = 'DOMMouseScroll'; }else { var scrollEventType = 'mousewheel'; } $(docum

佐罗的博客 849

js实现判断鼠标滚轮的上下滚动

<script type="text/javascript"> var scrollFunc = function (e) { e = e || window.event; if (e.wheelDelta) { //判断浏览器IE,谷歌滑轮事件 if (e.wheelD...

kingbow的博客 2726

防止页面图片过大出现横滚动条问题

由于今早碰到同事让我解决一个由于图片过大,导致在浏览器缩放窗口的时候出现了横向滚动条问题,后来在网上查询了下资料,也是为了能够让自己记住这个方法,现在把这个方法写出来,希望能够给大家做网站的时候一个参考 关于这个方法也是很简单,就是一小段JS,好吧废话不多说,下面把这段代码贴出来 jQuery(document).ready(function () { jQuery("body").a

json的博客 4111
上一篇: js学习笔记
下一篇: ofbiz学习笔记--form
kevin0xFFFFFFFF
博客等级 码龄17年 3粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值