473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Binding Event to innerHTML

Hi everyone,

I'm trying to figure out a way to some how 'bind an event' to the innerHTML property. As an example, if I do something like:

Expand|Select|Wrap|Line Numbers
  1. <containerElement>.innerHTML='some HTML code';
I would like somehow to be able to fire an event to accommodate the updated container content.

I just spent today and yesterday teaching myself prototypes and literals and all that cool stuff; from what I was able to pick up, I came up with the following unfunctioning script:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript" src="prototype.js"></script>
  2. <script language="javascript" type="text/javascript">
  3.  
  4. Object.prototype.initialize = function(){
  5.   this.innerHTML.bind(this.update());//I'm imagining you laughing at this line :)
  6. }
  7.  
  8. Object.prototype.update = function(){
  9.   alert('testing');
  10. }
  11.  
  12. var vCA;//Will contain an array of containers
  13.  
  14. window.onload = function(){
  15.   document.getElementById('containerDiv').initialize();//Make object into a container
  16. }
  17. </script>
I appreciate your time :)
Dec 9 '07 #1
2 4184
Ferris
101 100+
Hi

innerHTML is a property, not a function ,so it can't be applied with "bind".


by the way,the first parameter of bind is an object,so you should change the line
Expand|Select|Wrap|Line Numbers
  1. this.innerHTML.bind(this.update());//I'm imagining you laughing at this line :)
  2.  
into
Expand|Select|Wrap|Line Numbers
  1. this.innerHTML.bind(this.update);
  2.  

hope it helps.
Dec 9 '07 #2
Hey,

I appreciate your help, I'm probably going to go for an alternate route.

Thanks
Dec 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Tim Fooy | last post by:
Hi all, I have the following problem. In my page i have a large <div> with tags inside it that have event handlers on them (onclick etc.). When i run div.innerHTML = moreText + div.innerHTML,...
2
by: RobG | last post by:
I have a set of HTML elements that I add an onclick event to at runtime. All it does is get the contents of an element using innerHTML. It all works fine in Firefox, but I can't get it to work...
6
by: Tom | last post by:
Hi, In the following code I have reproduced a problem in IE that is extremely annoying for my application. <html> <head> <script type="text/javascript">
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
6
by: Murray Hopkins | last post by:
Hi. THE QUESTION: How do I get a reference to my Object when processing an event handler bound to an html element ? CONTEXT: Sorry if it is a bit long. I am developing a JS calendar tool....
2
by: charlesjylee | last post by:
I am working with Netscape 7.0 and need to bind a <divwith the innerHTML property. More specifically, I need to bind a GridView in the div in question. I am binding the div with some hardcoded...
2
by: swethak | last post by:
Hi, i am getting the problem when i used the onclick event in option tag.It is working fine in mozilla .But it is not working IE. Here is my code <script>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.