Hey, Jake

Cud u send me a sample complete SmartSourceDataCollectorScript
code.....jus need to luk-in de porbs being faced by ppl over here...

rgds.
Jack

On Jun 18, 8:41 pm, "Jake McGraw" <[EMAIL PROTECTED]> wrote:
> anyone?
>
> On 6/15/07, Jake McGraw <[EMAIL PROTECTED]> wrote:
>
>
>
> > This is all very interesting, maybe there is a bug in jQuery with the
> > ready event for IE6?
>
> > Because after the ready event fires, keep in mind, the ready event is
> > NOT part of the JS standard and it is entirely up to jQuery to
> > determine what "ready" is, execution control should be sent back to
> > whatever was running beforehand.
>
> > I was just reading about how IE's memory manager for DOM is separate
> > from their JScript engine, could it be that DOM processing occurs
> > while dcs_main() is running and then triggers the "ready" event when
> > it reaches the bottom of the document?
>
> > Could an expert chime in on this?
>
> > - jake
>
> > On 6/15/07, Theo Welch <[EMAIL PROTECTED]> wrote:
> > > Thanks for the help, the clear explanations and the time you spent, guys.
>
> > > I should point out that none of my jQuery code inside the
> > > $(document).ready() is manipulating the <img /> tag created by the 
> > > WebTrends
> > > script. My jQuery scripts are totally separate and unrelated to the
> > > WebTrends scripts (at the moment).
>
> > > I just want to try to make this all as clear as possible for myself and 
> > > for
> > > anyone coming upon this thread in the future. As you deftly pointed out
> > > Jake, the $(document).ready() is *delaying the execution* of my jQuery 
> > > code
> > > inside it. So while:
>
> > > $(document).ready( function() {
> > >    /do stuff
> > > });
>
> > > ...is *evaluated* (loaded) first in the browser, none of the "//do stuff"
> > > code inside $(document).ready() is *actually executed* before the 
> > > dcs_main()
> > > function is invoked (since the dcs_main() function is invoked directly in 
> > > a
> > > script tag, embedded in the page).
>
> > > So the code inside the dcs_main() function actually *does execute before*
> > > the code inside $(document).ready() starts to execute, even though the
> > > $(document).ready() code comes first in the document. So, I don't think 
> > > that
> > > moving the jQuery code to be below the call to dcs_main() would have any
> > > effect on this IE6 problem.
>
> > > And (I may be wrong here) but I suspect that IE 6 is firing the
> > > $(document).ready() event exactly when it thinks the document is ready, 
> > > but
> > > it doesn;t consider any currently executing JavaScript in whether or not 
> > > the
> > > document is "ready." Therefore my jQuery code gets started even though the
> > > dcs_main() function hasn't finished its execution. I think this "bad
> > > behavior" on IE's part is what causes the so-called "DOM collision" in IE6
> > > that effectively prevents the WebTrends <img /> tag from getting appended 
> > > to
> > > the DOM.
>
> > > It's as if IE6 "hijacks" the single JavaScript thread that dcs_main() is
> > > currently executing within when the $(document).ready() event is 
> > > triggered,
> > > so the dcs_main() function never (or very rarely) gets a chance to finish.
> > > It's like the JavaScript thread is simply "reset" in IE 6. I hope that 
> > > makes
> > > sense.
>
> > > And there also lies "the rub" with Jon's good idea of attaching a .load()
> > > event to the WebTrends <img /> tag: the <img /> tag never gets inserted 
> > > into
> > > the DOM by the WebTrends JS (since the dcs_main() function is
> > > short-circuited when the JS thread is hijacked), so the image will 
> > > actually
> > > never load. :)
>
> > > I think I will go ahead and use the "backup measure" methodology I
> > > envisioned. I will add some code to my $(document).ready() that will check
> > > (in IE 6 only) for the existence of the WebTrends <img /> tag in the DOM 
> > > and
> > > if it does not exist, I will invoke the dcs_main() function from within 
> > > that
> > > conditional (which will be inside the $(document).ready() ). I'll post the
> > > final, (hopefully) working code after I have tested it.
>
> > > If anyone else can think of any other ideas, I'm all ears. :)
>
> > > Thanks again, guys.
> > > -THEO-
>
> > > On 6/15/07, Jake McGraw < [EMAIL PROTECTED]> wrote:
>
> > > > JavaScript is a single thread/process and executed in the order (top
> > > > to bottom) of the page. To provide additional functionality, JS has a
> > > > series of events, which interrupts the standard execution order
> > > > (onclick, onload, onblur, etc...), the $(document).ready() binds a
> > > > callback function to the document object to fire during the "ready"
> > > > event. What is most likely occurring in your case:
>
> > > > <script>
> > > > $(document).ready(function(){
> > > > // Do some stuff
> > > > });
> > > > </script>
> > > > ...
> > > > <body>
> > > > ...
> > > > <script>
> > > > dcs_main();
> > > > </script>
> > > > </body>
>
> > > > The "ready" event won't fire until the HTML for the entire document is
> > > > loaded, while the dcs_main() function will fire as soon as it's
> > > > reached by the parser. Normally, I would suggest using:
>
> > > > $(document).load(/* callback goes here */);
>
> > > > To halt the execution of your code until all of the document images
> > > > are loaded, but since you're using JS to modify your DOM during
> > > > parsing, the onload event may fire before the image is actually
> > > > loaded, because it isn't detected as part of the original document.
> > > > So, my suggestion is to do one of the following:
>
> > > > A. Try changing $(document).ready() to $(document).load()
>
> > > > B. Place all your JS at the bottom of your document, like so:
> > > > <script>
> > > > dcs_main();
> > > > /* jQuery code goes here */
> > > > </script>
> > > > </body>
>
> > > > C. Continue doing what you're doing, there's nothing wrong, as far as
> > > > I know, with using the $(document).ready() callback to call other
> > > > functions.
>
> > > > Disclaimer: This one really made me think, so everything I said above
> > > > may not be right.
>
> > > > - jake
>
> > > > Mike answered the main question here, but just to clarify:
>
> > > > .load() or .bind('load') is the jQuery way to respond to the "onload"
> > > > event. This event only gets fired when the element it is attached to
> > > > is *completely* loaded. That means images, etc. must be completely
> > > > transferred before the event fires. The .ready() method of jQuery
> > > > registers code that will run when the DOM is ready, which could well
> > > > be quite a bit before the "onload" event occurs for the page.
>
> > > > It is possible to attach an onload handler to an individual element
> > > > (e.g. image) though, which can be useful.
>
> > > > --
> > > > Jonathan Chaffer
> > > > Technology Officer, Structure Interactive
>
> > > > On 6/15/07, skyeflye <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi all,
>
> > > > > I have a client that is running WebTrends for a large, enterprise web
> > > > > site. The way WebTrends works is very simple, and similar to many
> > > > > other user-tracking software. There is a chunk of WebTrends JavaScript
> > > > > code (they call it the "SmartSource Data Collector Script"), embedded
> > > > > in the bottom of every page's source code. This script basically just
> > > > > gathers several environment variables and then appends a new <img />
> > > > > tag to the DOM. The source (src) for the image tag is loaded from a
> > > > > separate web server that is running the WebTrends software. So, when
> > > > > the WebTrends server receives the request for this tiny image, it logs
> > > > > the visit to the page in its WebTrends database.
>
> > > > > The "SmartSource" script (embedded at the bottom of every web page)
> > > > > just defines a function and then immediately invokes it, like this:
>
> > > > > function dcs_main() {
> > > > >     // collect client info;
> > > > >     // create a new <img /> object;
> > > > > }
> > > > > dcs_main();  //immediately invoke the above function
>
> > > > > The problem I am having is that 99% of the time, IE6 is not finishing
> > > > > the execution of the WebTrends code, so the special <img /> tag is not
> > > > > getting appended to the DOM. This is obviously bad because then the
> > > > > visit to the page is not recorded by WebTrends.
>
> > > > > I also have a few simple jQuery DOM manipulations firing on $
> > > > > (document).ready(). Based on some testing, my theory is that in IE6,
> > > > > the WebTrends dcs_main() function is beginning its execution but it
> > > > > never finishes because while it is running, my simple jQuery DOM
> > > > > manipulations also begin, and the two scripts "collide" when they both
> > > > > try to change the DOM at the same time. There are never any errors or
> > > > > anything. I guess I am actually lucky that only IE6 is having this
> > > > > problem since any browser might have a problem with DOM manipulation
> > > > > collisions.
>
> > > > > One potential solution is to re-invoke the WebTrends dcs_main()
> > > > > function from inside the $(document).ready() event IF the special
> > > > > image tag has not already been added to the DOM. That way, if the
> > > > > dcs_main() function was "short-circuited" by the jQuery scripts (or if
> > > > > it was somehow not invoked at all), it would definitely be re-invoked
> > > > > from inside the $(document).ready() event. This "backup measure" could
> > > > > help to ensure that the <img /> was appended to the DOM no matter what
> > > > > and that the visit to the page was properly recorded by WebTrends.
>
> > > > > I am just wondering if anyone else could recommend a solution with a
> > > > > different methodology that might not require this kind of "backup
> > > > > measure" approach. For example, if there was any way to perhaps delay
> > > > > my jQuery scripts in $(document).ready() from running until after the
> > > > > WebTrends <img /> tag had been appended to the DOM (which will happen
> > > > > nearly instantaneously anyway).
>
> > > > > Thanks!- Hide quoted text -
>
> - Show quoted text -

Reply via email to