XML Elves

XML Elves

<community>of XML and SVG Developers</community>


How to copy SVG into clipboard using JavaScript?

This is a discussion on How to copy SVG into clipboard using JavaScript? within the SVG Questions forums, part of the SVG Forums category; Hello everybody. I interest in the folowing... While right-click on the SVG canvas there is pop-up menu option named "Copy ...


Go Back   XML Elves > SVG Forums > SVG Questions

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices


Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-22-2003, 10:33 PM
Junior Member
 
Join Date: Sep 2003
Posts: 17
Default How to copy SVG into clipboard using JavaScript?

Hello everybody.
I interest in the folowing...
While right-click on the SVG canvas there is pop-up menu option named "Copy SVG" which copy SVG into clipboard .Could you pls help me how to copy SVG content into clipboard using JavaScript.I want the the same effect like if have been chosen the mentioned option, but not from that pop-menu...
__________________
rbeit gibt die Freilesung!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-24-2003, 06:56 AM
jonfrost
Guest
 
Posts: n/a
Default How to copy SVG into clipboard using JavaScript?

Hello Cadok,

Please take a look at this example :
http://www.mecxpert.de/svg/domtree.html

It is very powerful for grabbing the current SVG DOM tree using Javascript.

HTH (hope this helps),
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-03-2003, 11:27 PM
Anonymous
Guest
 
Posts: n/a
Default How to copy SVG into clipboard using JavaScript?

Hello johnfrost!
I've already used this example, but I found some trouble there
It works only while saving SVG-tree for the first time...
When I try to save again nothing changes on the display, but such coment appears:
"junk after line ..."
This means that after ending tag </svg> the script writes again <svg> and writes svg-tree again not destroying previous tree. :?
So could you pls post me some another workable samles to study and compare.
Thank for al :lol: l
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-04-2003, 07:06 AM
Jon Frost
Guest
 
Posts: n/a
Default How to copy SVG into clipboard using JavaScript?

Yeah, it gets tricky,

To save your changes - use postURL to send your SVG DOM content to the url of your choice. You can then grab your SVG DOM there.

Or if using Adobe SVG Viewer try this :

<?AdobeSVGViewer save="snapshot"?>
<svg onload="initiate(evt)">
<script type="text/javascript">
<![CDATA[
function initiate(evt) {
var circ = document.createElement("circle");
circ.setAttribute("cx",60);
circ.setAttribute("r",20);
document.rootElement.appendChild(circ);
}
]]>
</script>
</svg>

Of course you can also use printNode() and put result in alert to quickly verify what happened.

Let me know if you would like a more detailed example of any of these approaches.

Best,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-19-2003, 06:43 AM
Junior Member
 
Join Date: Sep 2003
Posts: 17
Default Re: How to copy SVG into clipboard using JavaScript?

Quote:
Originally Posted by Jon Frost
Yeah, it gets tricky,

To save your changes - use postURL to send your SVG DOM content to the url of your choice. You can then grab your SVG DOM there.

Or if using Adobe SVG Viewer try this :

<?AdobeSVGViewer save="snapshot"?>
<svg onload="initiate(evt)">
<script type="text/javascript">
<![CDATA[
function initiate(evt) {
var circ = document.createElement("circle");
circ.setAttribute("cx",60);
circ.setAttribute("r",20);
document.rootElement.appendChild(circ);
}
]]>
</script>
</svg>

Of course you can also use printNode() and put result in alert to quickly verify what happened.

Let me know if you would like a more detailed example of any of these approaches.

Best,
Of course I'd like to study some more new examples.... :lol:
It preferable to have some alternative meanings of clipping into clipboard 8)
Thank you lot...
__________________
rbeit gibt die Freilesung!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-20-2003, 10:38 PM
Jon Frost
Guest
 
Posts: n/a
Default Re: How to copy SVG into clipboard using JavaScript?

Unfortunately you can't copy directly to the OS clipboard using the standard ASV v3/v6 software. However, I have heard that this may be possible using ASV if you are using IE with a 'trusted' website. Then with ActiveX you could grab the SVG image data with something like this : window.clipboardData.setData('yourText',yourString ). But this restricts you to one specific environment.

I've also read in a post by Doug Scheppers that another option would be to install Batik on your web server:
http://xml.apache.org/batik/svgrasterizer.html
Then you can rasterize your SVG image on the server and in IE you can use script to copy this raster image to the user's clipboard.

Those are the only known options at this time.

Regards,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
clipboard, copy, javascript, svg


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 05:37 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

Inkjet Printer Cartridges
High quality low cost inkjet printer cartridges from Prink. Free UK delivery on compatible inkjet printer cartridges. We stock over 50,000 cartridges

replacement ink cartridges
Get replacement ink cartridges from a trusted specialist supplier. We stock major brands and our own guaranteed compatible cartridges.

Hard disk drive repair recovery manchester
Problem with your hard disk drive? Contact Data Clinic in Manchester for the best repair and data recovery service.

ink cartridges Free UK Delivery on ink cartridges such as Canon, Dell, Epson, hp & Lexmark.

1 2 3 4 5 6 7 8 9 10