![]() | |
![]() |
| | Thread Tools | Display Modes |
#61
| ||||||
| ||||||
|
|
How do you debug code that doesn't exist anymore? There are more reasons to leave it than there are to remove it. It is a choice. I choose to leave mine. |
|
Run it in a Mac browser and your success ratio (across browsers) will drop to around 50% or so as there are at least 7 (probably more) that don't support setting the .text property on a script element and 6 (that I know of) that do support setting it. I say 50% simply because I am pretty sure the statistics there are skewed as I don't have a mac to investigate with. You can view the listings here: URL:http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/ Scroll down to the MAC OS'es and look at the column under the "Change .text" button. |
|
The only browser, that I know of, that doesn't support createElement on a SCRIPT element is IE and that is what has led to a lot of this coding is an effort to cope with IE not implementing createElement on a script element. If it did, you would code it like this: var newScript = document.createElement('script'); newScript.type = "text/javascript"; newScriptText = "alert('createTextNode worked')"; var s = document.createTextNode(newScriptText); newScript.appendChild(s); It's a simple proposal enanchment, however I tested my proposal with every used IE (5,5.5,6,7) and it seems to work perfectly. Maybe You're talking about Mac IE 5.X .... this death browser? No, I am referring to the fact that if IE supported - properly - createTextNode on a SCRIPT element then the entire thing would be trivial. It isn't because of IE. |
|
Do You write code for IE4 too? In this case, good luck for your solution!!! Can I inject scripts in IE4? Who cares? No, I don't develop for IE4 but I do develop with a mindset of at least having it fail gracefully instead of puking errors all over the user. Since you mention IE4 though, I *can* inject scripts in NN4. |
|
how many days did You spend to perform this research? My research as far as script injection is concerned has been going on for over 7 years now and I would not even be able to come close to guessing how much time I have spent on it. Can I do it? Absolutely. Can Imakeit work in any browser that can handle Dynamic Script Insertion? Yes I can. Does your code do that? Not even close. |
|
Your script does not work with NS6.0 Windows. Your script does not work with NS6.1 Windows. Your script does not work with iCab 3.0.3 Mac. Your script does not work with IE5.2 Mac. Your script does not work with Shiira 1.2.2 Mac. Your script does not work with Sunrise 0.89 Mac. The only browser listed that your script doesn't work in that I can't inject script into is NS6.0/6.1. The rest of them? Absolutely. |
#62
| |||||||||
| |||||||||
|
|
Randy, First let me say I'm not sure of the right or wrong way to quote and maintain context in these newsgroups so please bear with me. I'm only here because I noticed this topic and thought the discussion was interesting and felt I had something of value to add. That said, please forgive any newbie posting errors and read on. |
|
You've had some pretty passionate discussions in this group regarding injected js so I'd guess you're still interested in finding an acceptable solution. You might be interested to try Ajile (http:// ajile.iskitz.com/). It's a JavaScript namespace and dynamic loading library I've created that imo addresses the cross-browser dynamic script loading issue quite well. I haven't as yet finalized NN4 support, but Ajile functions perfectly (as designed) in modern and early version browsers like IE 4, Opera 7 and Netscape 6. NN4 does actually work as far as namespacing and dynamic loading go, but the browser dies after completing loading for an as yet undetermined reason (I'm still partially troubleshooting that one). |
|
I'm very interested in your assessment of Ajile as you seem to be fairly focused on finding a solution to the problem and are aware of some of the more challenging aspects of that search. Ajile is the end product of now nearly four years on and off effort to refine and expand a concept I originally implemented back in 2003 as JSPackaging. Although your reason for seeking a solution was slightly different than my motivation to create it, I believe Ajile solves a good part, if not all of both our problems. |
|
Below I'll try to respond to some of the points you've raised in your conversations with Andrea, in relation to Ajile: On Aug 30, 10:07 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: How do you debug code that doesn't exist anymore? There are more reasons to leave it than there are to remove it. It is a choice. I choose to leave mine. Ajile also removes script tags, though not immediately and provides multiple ways to enable/disable that feature (cloaking). I've found controlling cloaking to be very useful when debugging. In my testing and use I haven't encountered any garbage collection problems around script tag removal, maybe you can offer an effective way to verify this. I don't believe the removal of script tags affects the availability of code that has already been processed. I *have* found that the timing for when you choose to remove script tags is important as removing one while it's being processed can crash IE. |
|
Run it in a Mac browser and your success ratio (across browsers) will drop to around 50% or so as there are at least 7 (probably more) that don't support setting the .text property on a script element and 6 (that I know of) that do support setting it. I say 50% simply because I am pretty sure the statistics there are skewed as I don't have a mac to investigate with. You can view the listings here: URL:http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/ Scroll down to the MAC OS'es and look at the column under the "Change .text" button. Ajile implements multiple dynamic script loading strategies and should work for most if not all the browsers you've listed on your test page. I'd be interested to see what you find if you're able to test it in the listed environments. |
|
The only browser, that I know of, that doesn't support createElement on a SCRIPT element is IE and that is what has led to a lot of this coding is an effort to cope with IE not implementing createElement on a script element. If it did, you would code it like this: var newScript = document.createElement('script'); newScript.type = "text/javascript"; newScriptText = "alert('createTextNode worked')"; var s = document.createTextNode(newScriptText); newScript.appendChild(s); It's a simple proposal enanchment, however I tested my proposal with every used IE (5,5.5,6,7) and it seems to work perfectly. Maybe You're talking about Mac IE 5.X .... this death browser? No, I am referring to the fact that if IE supported - properly - createTextNode on a SCRIPT element then the entire thing would be trivial. It isn't because of IE. A subtle point easily missed by those who haven't taken the time to investigate the root cause. |
|
how many days did You spend to perform this research? My research as far as script injection is concerned has been going on for over 7 years now and I would not even be able to come close to guessing how much time I have spent on it. Can I do it? Absolutely. Can Imakeit work in any browser that can handle Dynamic Script Insertion? Yes I can. Does your code do that? Not even close. I applaud your 7 year effort, it's definitely not been an easy task, and it really requires a clear understanding of the JavaScript language and the various browser environments. |
|
Your script does not work with NS6.0 Windows. Your script does not work with NS6.1 Windows. Your script does not work with iCab 3.0.3 Mac. Your script does not work with IE5.2 Mac. Your script does not work with Shiira 1.2.2 Mac. Your script does not work with Sunrise 0.89 Mac. The only browser listed that your script doesn't work in that I can't inject script into is NS6.0/6.1. The rest of them? Absolutely. Ajile doesn't currently work with iCab and I don't have IE 5.2 Mac to test, but it works flawlessly with the Shiira, Sunrise, and NS browsers you've listed. I'll be looking into iCab compatibility, not quite sure what the issue is there... |
|
If you plan to respond, please respond to the group as this email is rarely checked. |

#63
| |||
| |||
|
|
What I "specialize" in (if you want to call it that) is loading script files or text after the page has finished loading. And, getting the execution context correct. |
#64
| |||||||
| |||||||
|
|
Randy Webb wrote: What I "specialize" in (if you want to call it that) is loading script files or text after the page has finished loading. And, getting the execution context correct. Do you have a link to your latest function that does the script loading? |
|
I have a script-injecting problem on Firefox under certain conditions and I'd like to see if your script solves my issue (before I post a code example). |
|
I'm using the dynamic script loading technique, but doing it before the page has finished loading. On Firefox in a simple test page it works just fine, perhaps because the page has already finished loading. |
|
On some larger pages it can also work just fine, even where the page definitely has not finished loading. |
|
On some rarer pages though, it fails. The variables that should have been defined by the script inject, although they exist, they give back JS errors along the lines of "has no properties". |
|
Two seconds later if I re-try the same operation on that variable, it succeeds. |
|
So clearly the variables were created properly, they just weren't usable yet. |
#65
| |||
| |||
|
|
Stevo said the following on 9/23/2007 2:53 AM: Do you have a link to your latest function that does the script loading? Not on a web-page. The closest would be the last one I wrote and posted to Usenet but it won't solve the issue you are having. URL: http://groups.google.com/group/comp....f0d3199b27b32a Not completed yet but it will work in Firefox. |

#66
| ||||
| ||||
|
|
Randy Webb wrote: Stevo said the following on 9/23/2007 2:53 AM: Do you have a link to your latest function that does the script loading? Not on a web-page. The closest would be the last one I wrote and posted to Usenet but it won't solve the issue you are having. URL: http://groups.google.com/group/comp....f0d3199b27b32a Not completed yet but it will work in Firefox. What I'm having a problem with isn't actually script loading, it's script "creating" from a string. This following code is running in an iframe and trying to inject a function into the parent page (in the same domain). |
|
try { //next 3 lines are normally one line. broken up //just so the line lengths aren't too long here var pd=parent.document; var b=pd.getElementsByTagName('iframe').item(0); var bn=b.parentNode; var s=document.createElement('SCRIPT'); s.text="function test(){return 2;}"; if(bn) bn.insertBefore(s,bn.firstChild); |
|
//try and call the function we injected //this often fails with a message about //test not being a function, but the call //in the setTimeout works just fine. |
|
The call inside the try block fails when the page is cached, but the second call (from the setTimeout) works just fine. Both are run from the same context (inside the iframe). It's as if there's a timing issue. |
#67
| |||
| |||
|
|
What I'm having a problem with isn't actually script loading, it's script "creating" from a string. This following code is running in an iframe and trying to inject a function into the parent page (in the same domain) (and failing). It is a timing issue where Firefox isn't updating everything until the current execution exits. And even then it gets really weird with the way it does or doesn't update. That is because setTimeout causes the current execution to end and start another execution thread. After the current one ends, Firefox updates and all is fine. And, it is the only reliable way to get Firefox to update dynamic scripts. It isn't so much a timing issue as an execution context issue. |

![]() |
| Thread Tools | |
| Display Modes | |
| |