<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Abdul Qabiz's Blog from India - Latest Comments in Flex Component that injects Javascript in HTML host</title><link>http://abdulqabiz.disqus.com/</link><description>Abdul Qabiz on Web Technologies, Flash Platform, RIA, India - a developer and entrepreneur, from Kanpur, India, on web technologies, software, technologies, electronics, adobe flash platform (flex, flash, air), web, open source, linux, free software, usability, startups, etc.
</description><atom:link href="https://abdulqabiz.disqus.com/a_mxml_component_that_embeds_javascript_in_html/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 28 Jul 2011 05:04:56 -0000</lastBuildDate><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-267512373</link><description>&lt;p&gt;That's awesome! Keep it up. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Thu, 28 Jul 2011 05:04:56 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-253624753</link><description>&lt;p&gt;I love this. It makes what I was trying to do much simpler and neater:&lt;/p&gt;&lt;p&gt;&lt;a href="http://blog.giles.roadnight.name/2011/07/preventing-browser-from-closing-your.html" rel="nofollow noopener" target="_blank" title="http://blog.giles.roadnight.name/2011/07/preventing-browser-from-closing-your.html"&gt;http://blog.giles.roadnight...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Roadnight</dc:creator><pubDate>Sat, 16 Jul 2011 06:39:41 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-126831466</link><description>&lt;p&gt;Could that be because of size limit in ExternalInterface API?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Mon, 10 Jan 2011 11:11:08 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-109708274</link><description>&lt;p&gt;Hi Abdul! thanks for the code, I tested it on flex 4 and works great!!&lt;/p&gt;&lt;p&gt;I have a cuestion... I have a big class written in javascript (430 lines), I tested it with your code but it doesn't work, do you believe that it not works because is a big string?&lt;/p&gt;&lt;p&gt;Greetings.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">px87</dc:creator><pubDate>Thu, 09 Dec 2010 23:09:17 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16627809</link><description>&lt;p&gt;I tested my work with IE6, but yeah I might have missed this particulare use-case. You can modify the code to send a long string in chunks and then run the js code?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Tue, 15 Sep 2009 11:08:31 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16555154</link><description>&lt;p&gt;Arg!  Came across this same issue this weekend (figured I'd give this a try with my latest project at work).  We're currently using IE6 so I'm running across the URL length limitation.  I've been trying trim down everything that's unnecessary, but IE6 still keeps catching me with too much junk in the URL.  Maybe I'll try some kind of trimming function for my JS.  I'm trying to contain the JS within the Flex project, but in IE6, that's been proving difficult.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gareth Arch</dc:creator><pubDate>Sun, 13 Sep 2009 22:24:22 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178669</link><description>&lt;p&gt;@syeddiwan: Sorry for late response, I believe, you can capture events (from browser) when it's going to close and then let flex know about it. Now browser-unload event doesn't work consistenly in all browsers, in my opinion, hence I would rather rely on different approach.&lt;/p&gt;&lt;p&gt;1) Capture browser's unload event and do the cleanup (saving data, closing session, etc).&lt;br&gt;2) Warn user when he tries to close the browser, request him to save, exit or logoff using provided control in user-interface?&lt;br&gt;3) Maintain a persistent connection using sockets or xmlsocket, now that might be some work and requires server-side infrastructure.&lt;/p&gt;&lt;p&gt;#1 might not work in all browsers and #3 might be little too much for simple things. I see, #2 can be used to and it's safe and sound.&lt;/p&gt;&lt;p&gt;BTW! What you plan to do? I mean, a lot of people are generally confused with things "sessions" and "flex".&lt;/p&gt;&lt;p&gt;-abdul&lt;/p&gt;&lt;p&gt;I believe, you can&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Thu, 25 Jun 2009 00:13:55 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178668</link><description>&lt;p&gt;Hai Abdul :-&lt;/p&gt;&lt;p&gt;  it's very nice one,Right now i am doing session  based flex application,so while closing the browser i need to pass the flex event,can u please guide me,  &lt;br&gt;thanks in advance&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">syeddiwan</dc:creator><pubDate>Sat, 20 Jun 2009 02:50:26 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178667</link><description>&lt;p&gt;hi,&lt;br&gt;nevermind. i had just named the file differently from the class. it's all fixed now. thanks for the code!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Patrice</dc:creator><pubDate>Thu, 20 Nov 2008 21:22:01 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178666</link><description>&lt;p&gt;hi,&lt;br&gt;so i fixed the problem that said it could not resolve  to a component implementation (i think), by using  but now it has a problem with  "packages cannot be nested" in &lt;a href="http://javascript.as" rel="nofollow noopener" target="_blank" title="javascript.as"&gt;javascript.as&lt;/a&gt;&lt;br&gt;do you know what i could be doing wrong?&lt;br&gt;thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Patrice</dc:creator><pubDate>Thu, 20 Nov 2008 21:16:34 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178665</link><description>&lt;p&gt;hi,&lt;br&gt;thanks for this code. i'm trying to integrate multiple javascript files into a flex application. i copied the code from your &lt;a href="http://javascript.as" rel="nofollow noopener" target="_blank" title="javascript.as"&gt;javascript.as&lt;/a&gt; file and tried to use the javascript tag in a separate mxml component file but it didn't work. it says that it could not resolve  to a component implementation.&lt;br&gt;do you know what i could be doing wrong?&lt;br&gt;hopefully you're still getting messages about comments from this post!&lt;br&gt;thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Patrice</dc:creator><pubDate>Thu, 20 Nov 2008 19:53:06 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178664</link><description>&lt;p&gt;Would this work with the moteDaemon (&lt;a href="http://sourceforge.net/projects/motedaemon/)?" rel="nofollow noopener" target="_blank" title="http://sourceforge.net/projects/motedaemon/)?"&gt;http://sourceforge.net/proj...&lt;/a&gt;&lt;br&gt;I keep getting:&lt;br&gt;SecurityError: Error #2051: Security sandbox violation:&lt;br&gt;errors with this example.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Adam</dc:creator><pubDate>Sun, 09 Nov 2008 19:40:07 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178663</link><description>&lt;p&gt;Hi,&lt;br&gt;I noticed this very peculiar behaviour:&lt;br&gt;try putting this in a javascript function and execute it as you said:&lt;br&gt;alert ("aaaaaaaabbaaaaasdddddddddddd2aaaaaaaaaaaaaaa1sasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1");&lt;br&gt;I got differing results in different browsers. It basically does not work in IE6. All other javascript functions don't work also if on the same flex app or html page.&lt;br&gt;However this works in IE7 and Firefox. It only works in IE6 if the piece of code above is put into a normal html page and not executed through Flex.&lt;br&gt;wondering what's going on and if there is a workaround to the limit of characters in a string&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark</dc:creator><pubDate>Wed, 13 Jun 2007 22:47:02 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178662</link><description>&lt;p&gt;This is sweet! Do you know what browsers this works in?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">judah</dc:creator><pubDate>Fri, 08 Jun 2007 05:58:44 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178661</link><description>&lt;p&gt;@Aneesh: Put &lt;a href="http://JavaScript.as" rel="nofollow noopener" target="_blank" title="JavaScript.as"&gt;JavaScript.as&lt;/a&gt; in com/abdulqabiz/utils folder inside your project. Then you need import it or declare it in xml namespace&lt;br&gt;&amp;lt;mx:Application xmlns:mx="&lt;a href="http://www.adobe.com/2006/mxml" rel="nofollow noopener" target="_blank" title="http://www.adobe.com/2006/mxml"&gt;http://www.adobe.com/2006/mxml&lt;/a&gt;" xmlns:utils="com.abdulqabiz.utils.*" ....&lt;br&gt;If you are using JavaScript in ActionScript, import it:-&lt;br&gt;import com.abdulqabiz.utils.JavaScript;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Tue, 05 Jun 2007 12:04:39 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178660</link><description>&lt;p&gt;hi abdul...&lt;br&gt;i am using eclipse with flex plugin...but i get an error saying "could not resolve  to component implentation....where should i put &lt;a href="http://JavaScript.as" rel="nofollow noopener" target="_blank" title="JavaScript.as"&gt;JavaScript.as&lt;/a&gt; that u have mentioned and how should i run it in eclipse..&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aneesh</dc:creator><pubDate>Mon, 04 Jun 2007 13:07:21 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178659</link><description>&lt;p&gt;Thanks Joan,&lt;br&gt;I am not very good in RegExp, I have fixed it anyway. I am going to sit down and write down all the use-cases and write proper regexp patterns.&lt;br&gt;I guess, I would end up writing some kind of laxer/grammar :)&lt;br&gt;-abdul&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Mon, 05 Mar 2007 16:36:46 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178658</link><description>&lt;p&gt;The last update would make this crash:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;JavaScript&amp;gt;&lt;br&gt;&amp;lt;![CDATA[&lt;br&gt;location.href = "http://www.yahoo.com";&lt;br&gt;]]&amp;gt;&lt;br&gt;&amp;lt;/JavaScript&amp;gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;Mabybe you could evaluate that the double slash is not between quotes.&lt;br&gt;Cheers&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Joan Garnet</dc:creator><pubDate>Mon, 05 Mar 2007 12:35:33 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178657</link><description>&lt;p&gt;@Theo - I don't exactly remember why I used navigateToURL () or getURL ().. But there were some issues around it so I used navigateToURL (..)&lt;br&gt;May be it's newline character or comments or could be anything.. For simple statements/expressions ExternalInterface works.. but complex ones, it doesn't..&lt;br&gt;Please try to port one my examples, in separate post , using your technique and see if it works..&lt;br&gt;Thanks&lt;br&gt;-abdul&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Mon, 05 Mar 2007 07:48:03 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178656</link><description>&lt;p&gt;Interesting idea, however, there is a much better way to do this than using getURL, check out my article on how to (ab)use the ExternalInterface to execute arbitrary JavaScript: &lt;a href="http://blog.iconara.net/2007/01/20/abusing-the-externalinterface/" rel="nofollow noopener" target="_blank" title="http://blog.iconara.net/2007/01/20/abusing-the-externalinterface/"&gt;Abusing the ExternalInterface&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;yours,&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;T#&lt;br&gt;&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">iconara</dc:creator><pubDate>Mon, 05 Mar 2007 07:17:47 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178655</link><description>&lt;p&gt;Neat! Thanks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Charlton</dc:creator><pubDate>Thu, 29 Jun 2006 20:10:22 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178654</link><description>&lt;p&gt;Tim, glad to know that it helped you...&lt;br&gt;-abdul&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Thu, 29 Jun 2006 15:39:05 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178653</link><description>&lt;p&gt;Thanks for the code sample Abdul.  I used your class to inject javascript that sets the focus to an swf, instead of modifying the html wrapper page.  I think that mySWF.focus() only works in IE, but that's better than nothing.  At least now the function wont be accidentally overwritten by Flex Builder.&lt;br&gt;Best Wishes,&lt;br&gt;Tim Hoff&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tim Hoff</dc:creator><pubDate>Mon, 26 Jun 2006 23:32:49 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178652</link><description>&lt;p&gt;ah, I didnt know if you specified two of the same functions in javascript it would just override the previous one.&lt;br&gt;Use cases...&lt;br&gt;if your component relies on javascript and dont want to have to make sure the calling page contains a special wrapper.&lt;br&gt;Another being a way to hide your javascript logic, kinda of an encryption method.  Im not sure if there are Javascript debuggers that pay attention to eval()'ed calls.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Scotty</dc:creator><pubDate>Fri, 16 Jun 2006 13:37:21 -0000</pubDate></item><item><title>Re: Flex Component that injects Javascript in HTML host</title><link>http://www.abdulqabiz.com/blog/archives/2006/06/16/a-mxml-component-that-embeds-javascript-in-html/#comment-16178651</link><description>&lt;p&gt;Manish, remember this is the idea I discussed long. I wanted that compiler folks or FB team do that...&lt;br&gt;Anyways, hope this idea has some use-cases. I have some in my mind. I would post some examples.&lt;br&gt;Scotty, I tried using ExternalInterface then I realized I don't need it because it is one way call.  And I also faced issues you mentioned.&lt;br&gt;I have not checked but you can create multiple instances of JavaScript component and inject scripts...It should work, I am just using "eval()" to make it work.&lt;br&gt;If you try to inject a function, which is already present. New injection would override the things...&lt;br&gt;-abdul&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abdul Qabiz</dc:creator><pubDate>Fri, 16 Jun 2006 10:46:24 -0000</pubDate></item></channel></rss>