#83 ✓resolved
Sander Sõnajalg

scoping issues while loading external scripts?

Reported by Sander Sõnajalg | December 16th, 2009 @ 06:22 AM | in 1.2.x

This is the fragment of the HMTL file i am loading:

<script type="text/javascript">
    print(" ====== LOADING embedded script with pageTracker def");
    var pageTracker = _gat._getTracker("UA-2476765-1");
    print(" ====== FINISHED FIRST");
</script>

<script type="text/javascript" src="Visitestonia.com_files/search_est.js"></script>

This is the beginning of loaded external script search_est.js:

print(" ====== LOADING search_est.js");

// Google Images
pageTracker._addOrganic("images.google", "prev");

This is the Rhino execution output (never mind the "WARNING" log messages i've added to Rhino and the "[jsvalidate]" prefix prepended by Ant as I'm executing it with the Ant task wrapper that i'm currently working on.. these things don't change anything).

[jsvalidate] -- running Main#processFileSecure [jsvalidate] ====== LOADING embedded script with pageTracker def [jsvalidate] ====== FINISHED FIRST [jsvalidate] WARNING!! msg : Reference to undefined property "interval" (at line 0) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "type" (at line 5839) [jsvalidate] WARNING!! msg : Reference to undefined property "type" (at line 5839) [jsvalidate] INFO: [Wed Dec 16 2009 18:10:50 GMT+0200 (EET)] {ENVJS} loading allowed external script :Visitestonia.com_files/search_est.js [jsvalidate] -- running Main#processFileSecure [jsvalidate] ====== LOADING search_est.js [jsvalidate] ERROR: uncaught JavaScript runtime exception: ReferenceError: "pageTracker" is not defined. (at line 0) [jsvalidate] js: uncaught JavaScript runtime exception: ReferenceError: "pageTracker" is not defined.

Why I'm sure i haven't just screwed up my Rhino fork or environment is that indeed if i load the version of HTML-file where pageTracker reference is embedded, everything works as expected (i.e. it doesn't complain about pageTracker being null).

<script type="text/javascript">
    print(" ====== LOADING embedded script with pageTracker def");
    var pageTracker = _gat._getTracker("UA-2476765-1");
    print(" ====== FINISHED FIRST");
</script>

<script type="text/javascript">
    print(" ====== LOADING SECOND EMBEDDED SCRIPT");
    pageTracker.do_something();
</script>

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

a javascript browser environment

People watching this ticket

Attachments

Pages