为什么改变图像的来源,执行我的内联javascript
why changing source of image , execute my inline javascript
我刚刚创建了一个网页,使用pagememethods这样的
function get_frame() {
//send a request to change image named "1.jpeg" in path of "src/frames/1.jpeg"
PageMethods.GrabFrame(imgw, imgh, t, f);
}
function t() {
//refresh image source to new image and set timer
document.getElementById('dImg').src = "src/frames/1.jpeg?" +
new Date().getTime();
setTimeout(function () { get_desktop(); }, Main.IMGrefresh.value);
}
function f() {
//do nothing
var x = 0;
}
还使用了内联javascript和jquery,像这样
<script>
$("#cover").mousemove(function (e) {
var parentOffset = $(this).parent().offset();
var relX = e.pageX - parentOffset.left;
var relY = e.pageY - parentOffset.top;
move_mouse(relX, relY);
});
</script>
和一些asp.net客户端代码,如
<div id="dDiv">
<img id="dImg" alt="" src="" />
<div id="cover">
</div>
</div>
内联javascript位于html代码的末尾
所以move_mouse()
方法必须运行只有当用户移动他的鼠标,它正确移动,但它移动即使鼠标没有移动当图像刷新,我的意思是当图像刷新javascript,它运行move_mouse方法。
#cover {
position:absolute;
top:0px;
left:0px;
text-align:center;
background-color:Black;
height:200px;
width:300px;
border:0px none black;
margin:0px auto 0px auto;
filter: alpha(opacity=1);
-moz-opacity: 0.01;
-khtml-opacity: 0.01;
opacity: 0.01;
}
#dDiv {
position:relative;
text-align:center;
background-color:Black;
height:200px;
width:300px;
border:0px none black;
margin:0px auto 0px auto;
}
#dImg {
background-color:Black;
height:200px;
width:300px;
border:0px none black;
margin:0px 0px 0px 0px;
}
javascript
也在改变function resize() {
imgh = Main.IMGheight.value;
imgw = Main.IMGwidth.value;
$("#dDiv").css("height", imgh);
$("#dDiv").css("width", imgw);
$("#dImg").css("height", imgh);
$("#dImg").css("width", imgw);
$("#cover").css("height", imgh);
$("#cover").css("width", imgw);
}
啊,我自己又发现了,只需将鼠标事件移动到js函数并将其放在body onload中,因为内联javascript方法保存在catch中,并且该命令=> "new Date(). gettime();"使其刷新并获得新方法,因此这会触发事件
相关文章:
- 页面在我的javascript执行后重新加载,我不希望它这样做
- jQuery-将列表项的一个元素移动到同一项的另一个元素中+对我的列表中的每个项执行此操作
- 我的指令在ngRepeat和ngInclude之前执行,尽管默认优先级为0
- 如何使我的javascript在页面加载后继续执行
- 如果我需要限制它的执行速度,如何重构此代码
- 要将 Chrome 扩展程序更改为 manifest_version 2,需要执行哪些操作?我的扩展程序只是在弹出窗口中
- 我可以信任 JavaScript 中声明中的执行顺序吗?
- 默认事件发生后,我如何执行自己的代码
- 我的if条件的执行
- 使用下划线_.delay,我如何停止未来的执行并提供用户状态
- WebView加载URL(“javascript:XYZ”)在我的网络视图中执行了好几次
- 我的外部javascript没有执行
- 仅限Chrome:ajax冻结了我的JavaScript执行
- 函数在我的情况下无法执行
- 我怎么知道,我的Javascript执行
- 我的Ajax请求返回成功,但脚本不是't已执行
- 子操作不允许在我的模态形式中执行重定向操作
- 我的 CSS 规则在我的 jQuery 函数执行后加载
- 没有对CSS使用外部样式表,导致我的代码无法执行
- 为什么我的PHP函数没有由jQuery $.get执行