473,658 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copy & paste

Hi,

I would like to copy and paste a selected item on a web page I already
've a context menu when the user rigth click on an item.

I would like to draw a rectangle who carry about current mouse position
until the user click left to a position.

I know how to draw a rectangle and how to get mouse position, now I need
to know how can I draw the rectangle (move it with mouse coordinate)
until user click a point on the web page.

Thanks in advance :)
Jul 23 '05 #1
1 2071
"Alexandre Jaquet" <al***@floor.ch > wrote in message
news:d2******** **@news.hispeed .ch...
Hi,

I would like to copy and paste a selected item on a web page I already
've a context menu when the user rigth click on an item.

I would like to draw a rectangle who carry about current mouse position
until the user click left to a position.

I know how to draw a rectangle and how to get mouse position, now I need
to know how can I draw the rectangle (move it with mouse coordinate)
until user click a point on the web page.

Thanks in advance :)

I don't know if this will help you.

It draws a rectangle after the mouse is clicked twice.

A third click "hides" it by setting the rectangle's border to white.

<html>
<head>
<title>rectangl e.htm</title>
<script type="text/javascript">

// JavaScript Capture Mouse X-Y Position Script
// http://www.codelifter.com/main/javas...position1.html

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?tr ue:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captur eEvents(Event.M OUSEMOVE)

// Set-up to use getMouseXY function onMouseDown
document.onmous edown = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.s crollLeft
tempY = event.clientY + document.body.s crollTop
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
// draw rectangle with a pair of coordinates
rectangle();
return true
}

// Rectabnle code below:

var i = -1;
var x = [0,0];
var y = [0,0];

function rectangle() {
i++;
var d = document.getEle mentById("rect" );
// reset on third mouse click
if (i > 1) {
i = -1;
x = [0,0];
y = [0,0];
d.style.borderC olor = "#FFF";
document.body.s tyle.cursor = "default";
window.status = "";
return;
}
document.body.s tyle.cursor = "crosshair" ;
// get mouse X,Y coordinates
x[i] = tempX;
y[i] = tempY;
// status bar for testing
window.status = x[0] + "," + y[0] + " : " + x[1] + "," + y[1];
if (i != 1) return;
// calculate left, top, width and height
var xl, yt, xx, yy;
(x[0] < x[1]) ? xl = x[0] : xl = x[1];
(y[0] < y[1]) ? yt = y[0] : yt = y[1];
(x[0] < x[1]) ? xx = x[1]-x[0] : xx = x[0]-x[1];
(y[0] < y[1]) ? yy = y[1]-y[0] : yy = y[0]-y[1];
// draw rectangle
d.style.borderW idth = "1px";
d.style.borderC olor = "#000";
d.style.borderS tyle = "solid";
d.style.positio n = "absolute";
d.style.left = xl+"px";
d.style.top = yt+"px";
d.style.width = xx+"px";
d.style.height = yy+"px";
// status bar for testing
window.status += " = " + xx + " x " + yy + " pixels";
return true;
}
</script>
</head>
<body>
<div id="rect"></div>
</body>
</html>

I don't doubt that there's a better way to do this.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2627
by: Nelgonde | last post by:
Apologies for the basic nature of this question but I'm very inexperienced in Java. I've been given the task of disabling the cut/copy/paste functions (Ctrl-X,C & V) in our java dialogs and although some of the Bean-based ones have cut, copy and paste functions which can be overloaded, other things which use JTable, JList and the like seem less straightforward. So I was wondering if there was any standard way of tackling this problem?
1
2555
by: tabonni | last post by:
Hi all I want to create an ASP page, which can copy the real PDF files into the clipboard and then the user can paste it in Outlook message as attachments(it's like inserting attachments) My idea is: When user checked the checkboxes for the requested PDF files from ASP page and press the "Add To Clipboard" button, all requested PDF files will be copied into clipboard. Then, the user open MS outlook message and right click -> Paste all...
5
4326
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be copied into clipboard and then they can right-click -> paste into MS Outlook as attachments. How can I use clipboardData.setData function to do that? I saw a lot of examples they are just copy and paste text.
1
1699
by: Tomomichi Amano | last post by:
Hello. I was wondering how to paste-copy-cut-delete at a SELECTED SPOT in a textBox. Thanks in advance.
6
2617
by: NuB | last post by:
I have a winform and a menu on the form, It allows the users to copy and paste text from text boxes. I never had to do this before, how can I copy and paste text from one box to another?
0
1452
by: Mr. Murad Jamal | last post by:
hi guys, I have a textbox & a button in an .aspx page, when I hit the button i want a selected text to be copied to the clipboard AND paste it into the last cursor position on the textbox BOTH AT ONCE, that means, copying & pasting the text must happen together on the Button_Click event handler! when we use javascript to store the selected text into a variable, we must use this code snippet:
6
3148
by: roopashree | last post by:
hi, currently I am able to cut,copy and paste images for only one image. Suppose I have 4 images-then I should group all the images so that I can cut/copy all 4 images and paste them. How can I do this? I have used an array to store all the images. If you have any code for this please send it to me or a website link. Else logic as to how am I to Proceed.
6
3740
by: rakeshvthu | last post by:
hi all, can we disable the copy and paste option in edit menu bar of browser my customer does not want copying using any technique so can any one help how to disable that options copy and paste in menu bar using java script urgently required loooking for quick response
0
1696
by: kavi2012 | last post by:
Hi I used the following function to disable the cut, Copy & paste in the Textbox. It works fine for me when I use ctrl+C,ctrl+X & ctrl+V. function disable(e) { if(event.ctrlKey) { event.returnValue = false; } }
5
23481
by: deve8ore | last post by:
Hello, I have a Word document called (), a named range that will open up a new Word doc dependent on what a user selects in Excel. Could someone please guide me on how to set up VBA code to copy and paste ALL sheets in the Word doc and paste into Excel? The sheets normally contain a graph or two, so if it's a copy & paste special as a picture, that's fine. Any help would be appreciated. Thank you,
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.