Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I get javascript window.open inside htmlloader to work?

New Here ,
Mar 26, 2013 Mar 26, 2013

I Have an air app, which I'm building with Flash CS5, which loads my site through the Htmlloader class. My problem lies with the tweet buttons on my site. They use the window.open class in javascript to open in a new smaller window, but I just can't get it to work inside my app. Is there a way to do this, or if not a work around to make something like this work?

TOPICS
ActionScript
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013

Look into ExternalInterface

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2013 Mar 26, 2013

Cool, this looks perfect, but I'm quite new to air and I'm not sure how to even get started.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2013 Mar 26, 2013

The tutorials don't really help, I can't seem to get them to work properly with my htmlLoader. Heres my code:

    var htmlL:HTMLLoader;

     htmlL= new HTMLLoader();

     htmlL.width = 1200;

     htmlL.height = 662;

     htmlL.x = 0;

     htmlL.y = 38;

     htmlL.manageCookies = true;

     addChild(htmlL);

     htmlL.load(new URLRequest("mytwitterpage.html"));

And on my page, there is a default twitter button:

     <a href="https://twitter.com/intent/tweet?button_hashtag=TwitterStories" class="twitter-hashtag-button">Tweet #TwitterStories</a>

     <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

How do I make this button work with my htmlloader to open the tweet popup within my air app?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013

I´m not exactly sure why you want to build an AIR application that emulates a browser only  to be able to open a new browser window to have access to twitter.

It sounds more like a Goldbergmachine than a program that does sth. useful

Usually all of the large sewrviceproviders like facebook, twitter etc. have sth. that is called a webservice to interact with their services, most require a certificate and authentification to get acces,

thats why its called "https"...."s" meaning secure.

For integrating Twitter directly into your AIR app look here

I'm quite new to air and I'm not sure how to even get started

You definitively don`t start with integrating webservices (at all)

You should either aim lower to learn the ropes with AIR or hire someone.

Just my 2 cents 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2013 Mar 26, 2013

Maybe it sounds more complicated than it is, but my app is literally only the htmlLoader, the rest of my app is coded in html and css, then loaded into the app (The app is only really a viewport for my html, I did it this way because as3 is my weakest language). Maybe I should aim a bit lower and use languages I know better. Would there be a way to use the javascript window.open function inside air, and have the content of it load in an internal "popup" type dialog box inside the app? (Sorry for the bad explaination)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013

I see no problems in nesting multiple htmlLoaders but no easy way to open a browser window if the browser is not already open.

AIRs access is limited to certain directories. Otherwise you could mess up a machine with an air app pretty good.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2013 Mar 26, 2013

Really sorry for all this bother, I'm really not great at explaining things, but how could I code a "native" popup inside my air app, which is activated and populated using window.open or a "_blank" link from my loaded html document? (Again, really sorry for this)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013

Take your code form above and modify it like this:

var htmlL2:HTMLLoader;

     htmlL2= new HTMLLoader();

    

     htmlL2.load(new URLRequest("myNestedPage.html"));

htmL.addChild(htmlL2);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2013 Mar 26, 2013

Ok, so I did a bit of researching, and found this article on nativewindows (http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e17.html) , which might be what I'm looking for, but I just couldn't explain. Would there be a way to add an event listener to my htmlLoader, then get it to create on of these nativewindows, with the required url, when it's fired?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013

NativeWindows doesn`t mean you have access to any native applications`windows like your OS.

It basically means that you can create an AIR app that uses the systems chrone (so will look on a MAc like a MAc app, on a Windows Computer like a Windows executable. And yes you could create thousands of such popup-windows inside AIR but it won`t bring you nearer to solving your problem that you mentioned in the first post.

Unless you secretly changed the requirements without saying so 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2013 Mar 26, 2013

I think I'll just leave it, it seems more hassle than it's worth. But one more question (kind of related), how can I open a link on my html page loaded with htmlLoader in my default browser? I've tried navigateInSystemBrowser, but that just loads the initial page in the browser, which is not what I want. I promise I'll leave you alone after this!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 26, 2013 Mar 26, 2013

Should work.

There seems to be an undocumented behavior, that when you alter the location (_self,_parent,_top) property navigateInSystemBrowser defaults back to "false". So better set it explicitly with every Link you call.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2013 Mar 27, 2013
LATEST

Great! It worked perfect! Thanks for that!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines