0

I am trying to call a function when something is pasted into a field. Because I am using ext.net, I can not hardcode the function into the onpaste. This is why I am setting it from js.

$('#HtmlEditorFDEdit-inputCmp-iframeEl').contents().find("body").attr("onpaste", "alert('you pasted');");

This works, however I would like to call a function myFunction instead of alerting.

The following gives me a Uncaught ReferenceError: myFunction is not defined

$('#HtmlEditorFDEdit-inputCmp-iframeEl').contents().find("body").attr("onpaste", "myFunction();");

I tried moving the function around; from the bottom to the top of the external js file.

I am not even able to the following; (text is blank)

var text="asd";
$('#HtmlEditorFDEdit-inputCmp-iframeEl').contents().find("body").attr("onpaste", "alert(text);");

Any ideas as to what is going wrong?

Thank you!

starvator
  • 989
  • 1
  • 11
  • 26
  • seems that duplicated by http://stackoverflow.com/questions/12367417/html-onpaste-dosomething-as-invalid-attribute – Alex Filatov Dec 01 '14 at 20:29
  • @AlexFilatov I saw that post but believe it is wrong. according to many sites, onpaste is supported by all major browsers [w3](http://www.w3schools.com/jsref/event_onpaste.asp) – starvator Dec 01 '14 at 20:32

0 Answers0