http://jsfiddle.net/zzbar210/3/
我正在使用IE 11.0.9600.17280对此进行测试.如果我在SVG区域上移动鼠标时更改文本框,Internet Explorer会停止响应整个页面的鼠标事件(单击,移动),但我仍然可以使用键盘(键入,标记).我发现让鼠标控制的唯一方法是刷新页面.有时即使鼠标没有移动也会发生.
是什么造成的?有办法解决这个问题吗?
var pt;
$(document).ready(function(){
pt = document.getElementById("layout_area").createSVGPoint();
$("#layout_area").mousemove(function(event) {
$("#position").html(event.clientX);
// Convert x/y into SVG position
pt.x = event.clientX;
pt.y = event.clientY;
var svg = $("#layout_area")[0]
var matrix = pt.matrixTransform(svg.getScreenCTM().inverse());
var pos_x = matrix.x
var pos_y = matrix.y
$("#position").append("<br />( " + pos_x.toFixed(3) + ", " + pos_y.toFixed(3) + " )");
document.getElementById("text1_use").setAttribute("x",pos_x-200);
document.getElementById("text1_use").setAttribute("y",pos_y-200);
});
$("#label_text").keyup(function() {
document.getElementById("text1").textContent = $("#label_text").val().trim();
});
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="label_text" />
<br />
<svg width="400" height="200" viewbox="0 0 400 200" …
Run Code Online (Sandbox Code Playgroud)我试图解析一个文件,我得到一个奇怪的分段错误.这是我正在使用的代码:
#include <iostream>
using namespace std;
int main ()
{
FILE *the_file;
the_file = fopen("the_file.txt","r");
if (the_file == NULL)
{
cout << "Error opening file.\n";
return 1;
}
int position = 0;
while (!feof(the_file))
{
unsigned char *byte1;
unsigned char *byte2;
unsigned char *byte3;
int current_position = position;
fread(byte1, 1, 1, the_file);
}
}
Run Code Online (Sandbox Code Playgroud)
我用命令编译它
g++ -Wall -o parse_file parse_file.cpp
Run Code Online (Sandbox Code Playgroud)
如果我删除while循环中声明current_position的行,代码运行没有问题.我也可以将该声明移到unsigned char指针的声明之上,代码将无问题地运行.为什么它会在声明中出现错误?