ExternalInterface.call("window.location.host.toString") - apache-flex

I wrote a flex application that get the host string from the browser using this code
ExternalInterface.call("window.location.host.toString")
This line of code work prefectally to get the host string in both Firefox and Opera. However, when using IE, the returned string is always 'null'. I need to get such information from the browser. I know that there is a work around by defining a javascript function that get such string and calling that function from the application. However, my application require getting such information from a native source.
I was wondering if anyone had the same problem and managed to solve it, or if someone has any idea why I always get null in IE, but not when using Firefox and Opera
Edit 1:
Here is the HTML code for embedding the generated SWF file. Maybe this is useful to spot a mistake
<object id="myTest1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" height="330px" width="600px">
<param name="movie" value="http://www.website.com/test.swf" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent" />
<embed id="myTest1" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.website.com/test.swf" allowScriptAccess="always" wmode="transparent" height="330px" width="600px" flashvars=""></embed>
</object>
the id, classid, and the allowScriptAccess are set as shown
Any idea?
Edit 2:
for Lior Cohen
The Flex file is the example used in your first link. The sub-directory history contains history.js, history.css, and historyFrame.html. The HTML page that include the generated SWF file is like this
<html>
<head>
<!-- BEGIN Browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css"/>
<script src="history/history.js" language="javascript"></script>
<!-- END Browser History required section -->
</head>
<body>
<object id="file1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" height="330px" width="600px">
<param name="movie" value="file.swf" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent" />
<embed id="file2" pluginspage="http://www.macromedia.com/go/getflashplayer" src="file.swf" allowScriptAccess="always" wmode="transparent" height="330px" width="600px" flashvars=""></embed>
</object>
<body>
</html>
However, this is still not working as expected.
Edit 3:
I have spotted the problem, however, I cannot fix it. The problem has to do with the javascript engine of IE and not the ExternalInterface nor the object and embed HTML tags.
What I am doing in my case is write the object and embed tags into a div created using javascript and this div is appended to the end of the body using the DOM methods. However, such approach make the InternalInterface always return null in IE (but not in Firefox nor in Opera).
var swfDiv = document.createElement('div');
swfDiv.innerHTML = '<object id="test1" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="600" height="330"><param name="movie" value="http://www.website.com/test.swf" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="quality" value="high" /><embed id="test2" name="test2" src="http://www.website.com/test.swf" allowScriptAccess="always" allowFullScreen="false" quality="high" width="600" height="330" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
document.body.appendChild(swfDiv);
I tried to use document.write to append the HTML content, which made it work perfectly in IE, however, document.write wrote over the entire page (removing old content), which is something I don't want.
document.write('<object id="test1" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="600" height="330"><param name="movie" value="http://www.website.com/test.swf" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="quality" value="high" /><embed id="test2" name="test2" src="http://www.website.com/test.swf" allowScriptAccess="always" allowFullScreen="false" quality="high" width="600" height="330" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
Any idea how to fix this?
Thanks

Take a look at the following link. It should provide you with what you're looking for, without using ExternalInterface.call().
http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_7.html
As mentioned in the page above, for the BrowserManager class to offer its full functionality, the wrapper must include several supporting files (history.js, amongst others).
More information about how to obtain and use these supporting files can be found in the following link under the "Deploying applications that use deep linking" section.
http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_2.html

A quick search reveals you will have to set some extra attributes on the object to make it work in IE. Set id classId and scriptAccess (the last one to 'true' of course) to get this to work. (google for more info)
(Not tested.)
http://www.google.com/search?q=externalinterface+internet+explorer

The solution to the problem that is mentioned in "Edit 3" is basically to create the object tag and its parameter tags using DOM objects, instead of just specifying them as string for the innerHTML attribute. This will make the returned value of the ExternalInterface work in Internet Explorer. Here is an example:
var swfDiv = document.createElement('div');
var obj = document.createElement('object');
obj.setAttribute('id','test1');
obj.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0');
obj.setAttribute('width','600px');
obj.setAttribute('height','330px');
var param = document.createElement('param');
param.setAttribute('name','movie');
param.setAttribute('value','http://www.website.com/test.swf');
obj.appendChild(param);
param = document.createElement('param');
param.setAttribute('name','allowScriptAccess');
param.setAttribute('value','always');
obj.appendChild(param);
param = document.createElement('param');
param.setAttribute('name','wmode');
param.setAttribute('value','transparent');
obj.appendChild(param);
swfDiv.appendChild(obj);
document.body.appendChild(swfDiv);
document.getElementById('test1').setAttribute('classid','clsid:d27cdb6e-ae6d-11cf-96b8-444553540000');
Note 1: This will make it work with Internet Explorer, any other browser should use any of the method mentioned above in "Edit 3" of the question. You can detect the browser and use the proper code accordingly.
Note 2: the last line is required to make it work properly, and it has to be like that and at the end after adding the object to the document. I do not know why, probably it has to do with the weird browser behavior.

#AAA
Note 2: the last line is required to make it work properly, and it has to be like
that and at the end after adding the object to the document. I do not know
why, probably it has to do with the weird browser behavior.
Thank you very much ! I suppose it is a bug in IE. I wonder how you found out.

Using SWFObject (you'll find it at http://code.google.com/p/swfobject/) to place the Flash on the page also solves this problem in Internet Explorer.

Related

Suppressing the Tool Information in Adobe

I've been searching for a way to prevent the download of a PDF and I finally found one in HTML5. The code is really simple and is
<embed src="filename.pdf#toolbar=0&navpanes=0&scrollbar=0" width="500" height="375">
The things that suppress the adobe options is #toolbar=0&navpanes=0&scrollbar=0.
My question is, is there a way to do this in non-html5 code? I've tried the following:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width="99%" height="99%" id="pdf" style="position:absolute; z-index:-1;">
<param name="movie" value="filename.pdf#toolbar=0&navpanes=0&scrollbar=0">
<param name="quality" value="high">
<param name="wmode" value="opaque" />
<param name="Enabled" value="1" />
<param name="toolbar" value="0" />
<param name="navpanes" value="0" />
<param name="scrollbar" value="0" />
<param name="bgcolor" value="##FFFFFF">
<embed nav src="filename.pdf#toolbar=0&navpanes=0&scrollbar=0" quality="high" bgcolor="##FFFFFF" width="99%" height="99%"
name="2003map" align="" type="pdf">
</embed>
</object>
I am not 100% but try adding the values also into the <embed>
<embed nav src="filename.pdf" quality="high" bgcolor="##FFFFFF" width="99%" height="99%"
name="2003map" align="" type="pdf"
toolbar="0" navpanes="0" scrollbar="0"
</embed>
This doubling of info works for wmode so may very well work here too :)
as your users are using a client side engine to render the PDF document there is no way to stop them downloading or saving it. at some point or way the document arrives at the client machine. in case of html it's always easy to have all resources you serve to be saved.
you have to render it on the server if you don't what your pdf as pdf in any case on your client's machine.
you can use an obfuscated flash in combination with Flash Pdf viewer just like scribd and have the pdf's path hidden but this is not 100% secure, because the resource remains accessible, but you can return it as binary from a server side after your viewer swf has identified itself.

How do I embed a flash object in my MVC2 Application Home?

I need to put a Flash Object in my website developed on MVC2 .NET, however the third party who made it just gave me an html with this code.HTML errors apart I don't know how to put it on ASP.NET. Can you help me?
<table width="608" border="0" cellpadding="0" cellspacing="0" bgcolor="#F4F4F4">
<tr>
<td height="412">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="runtime" width="608" height="412" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="runtime.swf" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="FlashVars" value="Runtime_settingPath=modules/main/setting.xml&Runtime_isRemote=false&Runtime_init_module=module1&Runtime_init_scene=scene1.swf" />
<EMBED src="runtime.swf" FlashVars="Runtime_settingPath=modules/main/setting.xml&Runtime_isRemote=false&Runtime_init_module=module1&Runtime_init_scene=scene1.swf" quality=high bgcolor=#CCCCCC WIDTH="608" HEIGHT="412" NAME="runtime" swLiveConnect="true" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</object>
</td>
</tr>
</table>
See Embed video on a asp.net-mvc website question and the answers. The SWF Object works very well.
I used the JW FLV player together with this explanation: http://codevoyeur.com/Articles/15/ASP.NET-MVC-HtmlHelper-Extensions-for-the-JW-FLV-Media-Player.aspx in several asp.net mvc sites.
You can paste that in an MVC View. Views can have plain old HTML code.
I don't see how this is any different than embed a flash object in a page. Any error you may be getting is definitely unrelated to it being in asp.net MVC.
I did. It doesn't work. May be some of the tags might be wrong. However I'm not a flash expert. I could tell you that the HTML they sent me has 43 errors according to the HTML Validator.
We are not the ones to complain about it ;). Put it in the simplest html page, and send it back as a test case that it doesn't work.

Does Google index HTML content supplied by the Object tag

This might be a weird question, but I've been unable to find an answer. Assuming I were to use an Object tag to embed an HTML snippet from an outside source (different server), how does Googles spider view that data? Does it pull in the data source like a browser would or does it only view the alternate content found between the Object tags like an old browser would do?
Example:
<object data="http://www.remotehost.com/data/test.html" type="text/html" width="300" height="200">
alt : test.html
</object>
Does only the "Alt : test.html" get read, or does the source "data/test.html" also get indexed as if it were part of the page?
I basically have an HTML content that customers need to include in their pages without having to do it dynamically using whatever back-end they use to prepare their page (PHP, JSP or whatever). They need the simplest method that doesn't require much back-end work on their part. I'm curious if this method would allow them to have that content included in their search results (their site) and not be indexed as my content from my server (index as content for my domain).
Using Google's Developer Toolbox, and Fetch as Googlebot, I was able to see how the Google spider would interpret the page and it doesn't process the Object data at all. Too bad, I guess I'll have to find another solution.
It seems to me Google had started crawling for things in Object tag since May 2013 and this had caused massive trouble with us.
For example, consider the following Flash embed code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0"
width="464" height="419" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="http://www.example.com/user-guide/loader.swf" />
<param name="base" value="http://www.example.com/user-guide/" />
<param name="flashvars" value="datasource=data.xml" />
<param name="loop" value="false" />
<param name="menu" value="true" />
<param name="quality" value="best" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<embed src="http://www.example.com/user-guide/loader.swf" base="http://www.example.com/user-guide/"
flashvars="datasource=data.xml"
loop="false" menu="true" quality="best" wmode="transparent"
bgcolor="#ffffff" width="464" height="419" align="middle"
allowScriptAccess="always" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>
What I found is Google now starts to crawl the http://www.example.com/user-guide/ folder which supposed to be a directory path, result in massive 403 forbidden error!
Google has crawled, recognized and indexed object tags since July-2011. Anything that meets Schema.org standards has the potential to be interpreted and even included in search results where applicable.

Multiple JWPlayers on Wordpress page

I have a Wordpress site that has a large photo slider for the header. Within that slider, I have buttons to launch videos corresponding to the current image. These are being set by custom tags within multiple posts. All the data is being passed correctly (based off of looking at the source code), however, I can only get 1 video to play while the other 2 (3 total) just appear black and won't play anything at all.
Here is my embed code:
<div id="video-block'.$videoID.'" class="video-block-player hide">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'.$video_width[0].'" height="'.$video_height[0].'" id="video'.$videoID.'" name="video'.$videoID.'">
<param name="movie'.$videoID.'" value="player.swf">
<param name="allowfullscreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="wmode" value="transparent">
<param name="flashvars" value="'.$video_link[0].'&autostart=true&icons=false&mute=true">
<embed
type="application/x-shockwave-flash"
id="video'.$videoID.'"
name="video'.$videoID.'"
src="player.swf"
width="'.$video_width[0].'"
height="'.$video_height[0].'"
bgcolor="undefined"
allowscriptaccess="always"
allowfullscreen="true"
wmode="transparent"
flashvars="file='.$video_link[0].'&autostart=true&icons=false&mute=true"
/>
</object>
</div>
The $videoID is being set dynamically to ensure that elements like the div id's are unique, all other variables are being set and pulled from custom tags (and again, appear correct when I view source).
Does anyone have any suggestions as to what I might do to get multiple video players working on a single page? (Please note that I am using JWPlayer, but am not forced to use it if someone has a better solution, but that this embed code is already being launched from within another Plug-In [SlidePress] so plug-in options may not be the best solution.)
Thanks in advance for any and all help!
J
Try Firebug to see what's loading and not loading and what errors you get.

flashVars flex3

hi im trying to using flashVars however for some reason there not getting sent to my flex app.
Im embedding my object in a velocity file and here is the object embed code;
<object width="$!WIDTH" height="$!HEIGHT">
<param name="flashVars" value="maximizeUrl=http://maximizeUrl"/>
<param name="movie" value="$!SRC"/>
<embed src="$!SRC" width="$!WIDTH" height="$!HEIGHT"/>
</object>
any ideas why this is not happening for me?
I assume you're having problems with Firefox, which ignores the object tag, and uses the embed tag instead. You need to add the flashvars parameter as an attribute there as well:
<object width="$!WIDTH" height="$!HEIGHT">
<param name="flashVars" value="maximizeUrl=http://maximizeUrl"/>
<param name="movie" value="$!SRC"/>
<embed src="$!SRC" width="$!WIDTH" height="$!HEIGHT" flashVars="maximizeUrl=http://maximizeUrl"/>
</object>
Alternatively, you could use SWFObject to dynamically generate the embedding code.
I agree with the answer from David, use SWFObject or prefreably use the code that comes with flexbuilder. check out my answer for this question https://stackoverflow.com/questions/452402/how-to-make-javascript-talk-to-flash-ac3-embedded-with-swfobject-2-0#461727

Resources