December 10, 20187 yr I'm not all that great with Javascript and I might just be having a dense but I can't work out how to run an object method from a jQuery event handler. var myObject = Object.create(Parser); myObject.init(); myObject.registerEvents(); $("#button").click( myObject.registerEvents ); What the function does is copy the html in a textarea into an iFrame. Alternatively finding a way to update the rendering in the iFrame of the changed textarea's HTML.
December 10, 20187 yr You have to use .contents, the best i can do is provide a link at the moment link
December 10, 20187 yr 1 hour ago, PinkHammer said: What the function does is copy the html in a textarea into an iFrame. You want to be really careful with that, it can put you at risk of XSS attacks. somebody could just dump a link to a malicious script right in that.
December 10, 20187 yr 56 minutes ago, PinkHammer said: I'm not all that great with Javascript and I might just be having a dense but I can't work out how to run an object method from a jQuery event handler. var myObject = Object.create(Parser); myObject.init(); myObject.registerEvents(); $("#button").click( myObject.registerEvents ); What the function does is copy the html in a textarea into an iFrame. Alternatively finding a way to update the rendering in the iFrame of the changed textarea's HTML. The click method is deprecated in newer versions of jQuery, you should use .on() method instead. The reason why your code isn't working, is because the first argument to .click is a callback, where you can pass in a parameter to capture the event. $('#button').click(function(e) { console.log(e) }) Here's an example of what you're trying to do, but it's extremely dangerous. Like @rbrtsmith said, any malicious script in the textarea could be injected directly into the frame. You can try this yourself by dropping <script>alert()</script> into the textarea and submitting.
Create an account or sign in to comment