English 中文(简体)
Drag和Droop控制职位
原标题:Controlling Position of Drag and Drop

I have a textarea that starts with text I don t want the user to be able to change and are prevented in doing so by the following:

  • The left key and backspace work until it reaches the position of the undeletable text.
  • The up key has a special function and doesn t serve navigational purposes (returns false).
    • (With the previous two rules, the user cannot place the caret in this region via arrow keys)
  • When the user clicks the element, the caret is placed at the end of the textarea (on mouse down).
  • Home and ctrl+a have been handled too.

为了说明问题,它想看像什么。

Don t Delete Anything Before the Colon:  Your text here.  The user text will also
wrap like this.

我知道,我的情况只是一个:Drag和下降。 我知道,如何完全减少和减少,但这是我想要的。 我不想让不可磨灭的文本能够改变。 Can 在允许退学之前,我将给予照顾。 或者,我能否阻止退学,但能否进入退学事件,把它放在我喜欢的地方?

最佳回答

I figured it out, here s the gist:

为了避免混淆,我首先“hi”了OnDragOver和OnDragEnter。

function(event){
  event.preventDefault ? event.preventDefault() : event.returnValue = false;
}

然后,我阻止了OnDrop,但把数据放在我想要的地方。

function(event){
  element.value += event.dataTransfer.getData("Text");
  event.preventDefault ? event.preventDefault() : event.returnValue = false;
}
问题回答

我制定了解决办法。 它取决于 j,但熟练的JA方案管理员可以轻易消除这种依赖性Imure。

Live Demo:http://trafnar.github.com/permastring/

JS Code:

Github Repo: https://github.com/trafnar/permastring

它通过不断储存案文领域的价值而开展工作,从根本上消除任何改变永久特征的变化。

我迄今为止注意到的最大缺陷是,它破坏了用户选择所有+删除的能力。 Edit:我确定这一缺点,现在可以选择所有东西,删除。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签