/    Sign up×
Community /Pin to ProfileBookmark

contenteditable

[CODE]
var holder = document.getElementById(‘article’),
state = document.getElementById(‘status’);
if (typeof window.FileReader === ‘undefined’)
{
state.className = ‘fail’; }
else
{
state.className = ‘success’;
state.innerHTML = ‘File API & FileReader available’;}
holder.ondragover = function () { this.className = ‘hover’; return false; };
holder.ondragend = function () { this.className = ”; return false; };
holder.ondrop = function (e) {
this.className = ”;
e.preventDefault();
var file = e.dataTransfer.files[0],
reader = new FileReader();
reader.onload = function (event) {
var Img_Src =event.target.result;
document.execCommand(‘InsertImage’,null,Img_Src);
var xmlhttp;
if (window.XMLHttpRequest)
{ xmlhttp=new XMLHttpRequest(); }
else
{
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”); }
xmlhttp.onreadystatechange=function()
{
document.getElementById(‘condition_return’).innerHTML=xmlhttp.responseText;}
xmlhttp.open(“POST”,”index_services/upload.php”,true);
xmlhttp.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded”);
xmlhttp.send(“send=” + Img_Src + “&page_pointer=$page_pointer&key=$fetch_user_session_data[0]”); };
reader.readAsDataURL(file);
return false; };[/CODE]

ondragend and ondragover brakes the normal d&d of the images already in place and prevents dropping web images. i am new to javascript and am trying to complete a cms that is all done except for the client interface(this code) i am not afraid of looking dumb so let me hear it, please oh please. what am i doing wrong and/or could i do better. thx in advance(very very much).

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@DorkyauthorAug 26.2011 — ok, i have narrowed it down.

holder.ondragover = function () { if (What goes here?) { return false; } };

i need to discover if the draged element is from the browser and what is a file, or just what is a file as this is the only time this needs to be fired.i think...
×

Success!

Help @Dorky spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...