joergen
18.05.2001, 07:37
hi hoping someone can help me with this...
the dataTransfer.setData only seem to allow one value being passed, is this so? haven't been able to find any information concerning this. i mean, what's the purpose of being able to set two properties (URL and Text) if you can only set one at a time. one can just as well grab the url as text and pass it along that way (which actually is what happens - when URL is set, the Text property has the same value).
now what i'd like to do is transfer some image information - URL and text (actually a db guid) - to two seperate inputfields.
my code looks something like this:
<script>
function fnSetInfo()
{ // Sets data format in first parameter
window.event.dataTransfer.setData("URL", oSource.src); // and provides text to drop in second.
//window.event.dataTransfer.setData("Text", "OK"); <-- not working
window.event.dataTransfer.effectAllowed = "copy"; // Copies text.
}
function fnCancelDefault()
{ // Cancel default action in ondragenter
event.returnValue = false; // and ondragover so that copy cursor will
window.event.dataTransfer.dropEffect = "copy"; // display until selection is dropped.
}
function FinishDrag()
/* The parameter passed to getData tells the target
object what data format to expect. */
{
sImageURL = event.dataTransfer.getData("URL");
//sImageText = event.dataTransfer.getDate("Text"); <-- not working
bTarget.src = sImageURL;
//oTarget.value = sImageText; <-- not working
}
</script>
<body>
../images/house.jpg
<input type=image src="/jblokal/images/wbc-bild.gif" border=0 id=bTarget value="test" ondragenter="fnCancelDefault()" ondragover="fnCancelDefault()" ondrop="FinishDrag()">
</body>
am i doing something wrong or is this just the regular behaviour?
thanks for you help!
Joergen
the dataTransfer.setData only seem to allow one value being passed, is this so? haven't been able to find any information concerning this. i mean, what's the purpose of being able to set two properties (URL and Text) if you can only set one at a time. one can just as well grab the url as text and pass it along that way (which actually is what happens - when URL is set, the Text property has the same value).
now what i'd like to do is transfer some image information - URL and text (actually a db guid) - to two seperate inputfields.
my code looks something like this:
<script>
function fnSetInfo()
{ // Sets data format in first parameter
window.event.dataTransfer.setData("URL", oSource.src); // and provides text to drop in second.
//window.event.dataTransfer.setData("Text", "OK"); <-- not working
window.event.dataTransfer.effectAllowed = "copy"; // Copies text.
}
function fnCancelDefault()
{ // Cancel default action in ondragenter
event.returnValue = false; // and ondragover so that copy cursor will
window.event.dataTransfer.dropEffect = "copy"; // display until selection is dropped.
}
function FinishDrag()
/* The parameter passed to getData tells the target
object what data format to expect. */
{
sImageURL = event.dataTransfer.getData("URL");
//sImageText = event.dataTransfer.getDate("Text"); <-- not working
bTarget.src = sImageURL;
//oTarget.value = sImageText; <-- not working
}
</script>
<body>
../images/house.jpg
<input type=image src="/jblokal/images/wbc-bild.gif" border=0 id=bTarget value="test" ondragenter="fnCancelDefault()" ondragover="fnCancelDefault()" ondrop="FinishDrag()">
</body>
am i doing something wrong or is this just the regular behaviour?
thanks for you help!
Joergen