Javascript中的照片标记

Javascript中的照片标记,javascript,Javascript,我想知道的是如何使用JavaScript创建一个拖动选择框 我的意思是,当你点击鼠标左键并拖动时,一条“线”(我不知道它的名称)应该出现,就像在你的桌面上一样 在图像上单击并拖动,释放时,应在拖动区域下方显示搜索框 我相信这是可能的,但我没有找到任何例子。那么,你能帮我吗?有一些插件可以做到这一点。你可以尝试使用来实现你想要的 aeImageResize是一个jQuery插件,可以动态调整图像大小,而不会扭曲比例 示例 $(function() { $( ".resizeme" ).aeIm

我想知道的是如何使用JavaScript创建一个拖动选择框

我的意思是,当你点击鼠标左键并拖动时,一条“线”(我不知道它的名称)应该出现,就像在你的桌面上一样

在图像上单击并拖动,释放时,应在拖动区域下方显示搜索框


我相信这是可能的,但我没有找到任何例子。那么,你能帮我吗?

有一些插件可以做到这一点。你可以尝试使用来实现你想要的

aeImageResize是一个jQuery插件,可以动态调整图像大小,而不会扭曲比例

示例

$(function() {
  $( ".resizeme" ).aeImageResize({ height: 250, width: 250 });
});

扩展此插件,在
complete
函数中,您可以将其设置为文本区域。

有一些插件可以实现此功能。你可以尝试使用来实现你想要的

aeImageResize是一个jQuery插件,可以动态调整图像大小,而不会扭曲比例

示例

$(function() {
  $( ".resizeme" ).aeImageResize({ height: 250, width: 250 });
});

扩展这个插件,在
complete
函数中,你可以把它做成一个文本区。

我认为可以这样做

function getCursorPosition(e)
{
e = e || window.event;
if (e)
    {
    if (e.pageX || e.pageX == 0) return [e.pageX,e.pageY];
    var dE = document.documentElement || {};
    var dB = document.body || {};
    if ((e.clientX || e.clientX == 0) && ((dB.scrollLeft || dB.scrollLeft == 0) || (dE.clientLeft || dE.clientLeft == 0))) return [e.clientX + (dE.scrollLeft || dB.scrollLeft || 0) - (dE.clientLeft || 0),e.clientY + (dE.scrollTop || dB.scrollTop || 0) - (dE.clientTop || 0)];
    }
return null;
}

function mousedown(e)
{
var mxy = getCursorPosition(e);
var box = document.getElementById("sel_box");
box.orig_x = mxy[0];
box.orig_y = mxy[1];
box.style.left = mxy[0]+"px";
box.style.top = mxy[1]+"px";
box.style.display = "block";
document.onmousemove = mousemove;
document.onmouseup = mouseup;
}

function mousemove(e)
{
var mxy = getCursorPosition(e);
var box = document.getElementById("sel_box");
box.style.width = (mxy[0]-box.orig_x)+"px";
box.style.height = (mxy[1]-box.orig_y)+"px";
}

function mouseup(e)
{
var box = document.getElementById("sel_box");
box.style.display = "none";
box.style.width = "0";
box.style.height = "0";
document.onmousemove = function(){};
document.onmouseup = function(){};
}
document.onmousedown=mousedown


@Praveen Kumar

我认为可以这样做

function getCursorPosition(e)
{
e = e || window.event;
if (e)
    {
    if (e.pageX || e.pageX == 0) return [e.pageX,e.pageY];
    var dE = document.documentElement || {};
    var dB = document.body || {};
    if ((e.clientX || e.clientX == 0) && ((dB.scrollLeft || dB.scrollLeft == 0) || (dE.clientLeft || dE.clientLeft == 0))) return [e.clientX + (dE.scrollLeft || dB.scrollLeft || 0) - (dE.clientLeft || 0),e.clientY + (dE.scrollTop || dB.scrollTop || 0) - (dE.clientTop || 0)];
    }
return null;
}

function mousedown(e)
{
var mxy = getCursorPosition(e);
var box = document.getElementById("sel_box");
box.orig_x = mxy[0];
box.orig_y = mxy[1];
box.style.left = mxy[0]+"px";
box.style.top = mxy[1]+"px";
box.style.display = "block";
document.onmousemove = mousemove;
document.onmouseup = mouseup;
}

function mousemove(e)
{
var mxy = getCursorPosition(e);
var box = document.getElementById("sel_box");
box.style.width = (mxy[0]-box.orig_x)+"px";
box.style.height = (mxy[1]-box.orig_y)+"px";
}

function mouseup(e)
{
var box = document.getElementById("sel_box");
box.style.display = "none";
box.style.width = "0";
box.style.height = "0";
document.onmousemove = function(){};
document.onmouseup = function(){};
}
document.onmousedown=mousedown

@Praveen Kumar

URL链接:-

使用jQueryUIAPI

这是最好的拖动选择技术。

URL链接:-

使用jQueryUIAPI


这是最好的拖动选择技术。

Crosshair是您要查找的单词。感谢Crosshair是您要查找的单词。感谢Crosshair我不想调整图像大小。我想要实现的是这个演示,只使用纯javascriptComparison:纯JavaScript-1000行代码,无法维护,不能在所有浏览器下工作。jQuery—在大多数浏览器下都可以工作,代码不到100行,可维护@KishoreKumar考虑一下,让我知道。:)好的,我将使用jQuery如何获得演示中的结果?单击并拖动即可,发布后,我希望在拖动区域下方显示一个搜索框,用于标记朋友。我会做php部分。哈哈。。。在
complete
函数中,给出类似
$(this.append(“”)
或类似的内容:我不想调整图像的大小。我想要实现的是这个演示,只使用纯javascriptComparison:纯JavaScript-1000行代码,无法维护,不能在所有浏览器下工作。jQuery—在大多数浏览器下都可以工作,代码不到100行,可维护@KishoreKumar考虑一下,让我知道。:)好的,我将使用jQuery如何获得演示中的结果?单击并拖动即可,发布后,我希望在拖动区域下方显示一个搜索框,用于标记朋友。我会做php部分。哈哈。。。在
complete
函数中,给出类似
$(this.append(“”)
或类似的内容:我不想这样拖拖拉拉。在计算机屏幕上,您可以按住鼠标左键并拖动。我需要这种拖拽,当释放时,图像上的选定区域应该在那里,直到我标记朋友。我不想像这样拖拽。在计算机屏幕上,您可以按住鼠标左键并拖动。我需要这种拖动,当释放时,图像上的选定区域应该在那里,直到我标记朋友。