SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I create my own events with x (from Cross-browser.com)?

    I'm trying to get up to speed with the x cross-browser library and I have a problem I think would be addressed if I could generate my own events as I'm used to doing in Tcl ( http://tinyurl.com/3chedd#M40 ). But it's not clear to me from the xEvent documentation if I can do that. Can someone point me to more event examples with x or tell me if I can create my own event type with it?

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What kind of event(s) do you want to create?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Chris, Welcome to SPF!

    I'm glad you like X

    No, there's nothing in X that allows you to create events. That is, if I'm understanding your question correctly,

    You can create events (and dispatch them) using standard DOM2 methods.

    After looking at the TCL documentation you linked to - I don't think you want to "create an event".

    Like Kravvitz said, tell us exactly what you want. Do you want to listen for a particular keypress? Or know when the mouse is in a certain area? or etc...

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What I'm trying to do...

    I should know better. When I'm providing support and a customer asks a weird question I always say, "No, you can't do _that_ but what are you trying to accomplish? Maybe we can do it another way."

    I have a web page that consists of an index.html that has almost no content but a few things like:

    <div id='somestuff'></div>

    and code that tries to replace the innerHTML of that div with a file that's retrieved from the server. Often, those files have some scripting in them such as:

    <script src='somefunctiondefinitions.js'></script>
    <script language='JavaScript'>
    invokeAFunction();
    </script>
    ...

    My loading code does:
    // e is the div mentioned above, c is the file contents retrieved
    e.innerHTML = c;

    var scripts = e.getElementsByTagName('script');
    if (scripts.length > 0) {
    for (var i = 0; i < scripts.length; ++i) {
    var s = scripts[i];
    if (s.innerHTML) {
    eval(s.innerHTML);
    }
    if (s.src) {
    xSmartLoadScript(s.src);
    }
    }
    }

    But in some browsers, the eval() tells me that the function I want to invoke isn't defined. I imagine that the load of the script hasn't quite completed. In Tcl, I'd do

    after idle eval(s.innerHTML)

    which says "when you're finished rendering and processing all other events, evaluate the script" or bind to a virtual event and then send that event from my code which would put the event on the end of the event queue to be processed when everything before it is done. I'm looking for a way to do that deferred evaluation. I tried setting up an event handler for onload but that didn't seem to work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •