7

次のSWFコードを埋め込むことにより、個々のページで実行すると、新しいタブに目的のURLと広告バーが上部に表示されます。ユーザーの操作は必要ありません。

<embed width="1" height="1" align="middle"
       pluginspage="http://www.macromedia.com/go/getflashplayer"
       type="application/x-shockwave-flash" allowscriptaccess="sameDomain"
       name="blog" bgcolor="000000" wmode="transparent" quality="high"
       src="http://i1177.photobucket.com/albums/x348/hosting504/red.swf" 
       flashvars="web=www.agitehabbero.com/index.php&creador=supercito">

コードがフレームに埋め込まれている場合、新しいタブは作成されず、フレームが変更されてhtmlページが追加されます。

編集:ページにJAVASCRIPTはありません。

SWFファイルはこれをどのように行うことができますか?(コンテンツをWebページに挿入します)?

4

7 に答える 7

6

このActionScript3.0コードは無名関数を挿入し、単一のパラメーター「hello」を渡しながら実行します ExternalInterface.call("function(msg){ alert(msg); }", "hello");(これはこのJavascriptコードのように実行されます:) function(msg){ alert(msg); }("hello");

コードを挿入できるため、ドキュメントを操作するためのコードを記述できます(要素の追加、スタイルの変更、要素値の変更など)。たとえば、このAS3コードExternalInterface.call("function(){ document.write(\"Hello, world!\"); }");は「Hello、world!」と表示されます。HTMLページ。

また、ドキュメントから:

  • 含まれているHTMLページのSWFファイルのオブジェクトタグで、次のパラメータを設定します。 <param name="allowScriptAccess" value="always" />
  • SWFファイルに、次のActionScriptを追加します。 flash.system.Security.allowDomain(sourceDomain)

上記のすべてをテストしましたが、ブラウザ(Google Chrome 19、Internet Explorer 8、Firefox 12)で問題なく動作します。

あなたが要求したように、ドキュメント側にJavaScriptはありません:)

于 2012-06-05T18:29:44.160 に答える
3

AS3

package {
    import flash.display.Sprite;
    import flash.external.ExternalInterface;
    import flash.events.*;

    public class MyApp extends Sprite {

        private var btn:Sprite;

        public function MyApp() {
            //add an entry point from js (html page) to swf, so js can call the swfFunc
            ExternalInterface.addCallback('swfFunc', swfFunc);

            btn = new Sprite();
            btn.mouseEnabled = true;
            btn.x = 0;
            btn.graphics.beginFill(0xFF0000, 0);
            btn.graphics.drawRect(0, 0, 300, 50);
            btn.graphics.endFill();
            btn.addEventListener(MouseEvent.CLICK, jsFunc);
            addChild(btn);
        }

        public function jsFunc(evt:MouseEvent):void {
            // call the js function named jsFunc 
            ExternalInterface.call('jsFunc', 'Test JS');
        }

        //this method is called from the js
        public function swfFunc(text:String):void {
            trace(text);
        }
    }
}

HTML

<object id='MySWF' type='application/x-shockwave-flash' data='MyApp.swf' width='300' height='50'>
    <param name='movie' value='MyApp.swf' />
    <param name='allowscriptaccess' value='always' />
    <param name='swliveconnect' value='true' />
</object>

<div id="container">
    A Text
</div>
<button type="button" onclick="swfFunc();">Call SWF</button>

JS

function jsFunc(text) {
    document.getElementById('container').innerHTML = text;
}

function swfFunc() {
    var swfObj =  window['MySWF'] || documment['MySWF'];
    swfObj.swfFunc('Test SWF');
}
于 2012-06-01T13:21:54.573 に答える
3

ASには。というクラスがありExternalInterfaceます。これは、フラッシュがJSと通信するのに役立ちます(js関数を呼び出すか、JSがフラッシュ関数を呼び出します)。次に、DOMをスローして、ページにコンテンツを追加できます。これかもしれません。

于 2012-05-29T07:02:37.787 に答える
3

とった!
あなたが言ったように、Javascriptはありません。
卑劣なコード、理由は完全にはわかりませんが、なんとか機能させることができました。red.swfをダウンロードして逆コンパイルし、2つのフレームがあり、2番目のフレームだけに次のコードがあります(コメントは私のものです)

    /*

flashvars are loaded to the _root as following:
_root.web = www.agitehabbero.com/index.php&creador=supercito
oddly the amperesand (&) gets interpreted too so we also get.
_root.creador=supercito

*/
    stop();
    var url = _root.web;
    if ("supercito" == _root.creador) {//verifies that the url passed has a value pair creador=supercito I guess to avoid it being used for something else?
        getURL ("http://supercito.com.ar/g3/web.php?url=" + url, "glu");
        /* the getURL calls this site, in a new window (frames are treated as windows by browsers) 
        somehow flash , as it doesn't find the frame or window, converts it into a pop up */
    } else {
        getURL ("http://supercito.com.ar/404", "glu");
    }

ああ、これはほとんどActionScript 2ではなく、AS1(同じVMを使用)のように見えます。

さらにテストするために、フラッシュコードを簡略化して、サーバーにアップロードしました。

stop();
getURL ("http://supercito.com.ar/g3/web.php?url=" + _root.web, _root.marco);

サーバーでは、さまざまな入力を試して、何が起こるかを確認できます。リンクは次のとおりです:http: //m0.cl/t/dwit/assets/no-usar/testing-odd.php

(私が何か他のものの真っ只中にいた厄介なアドレスについては申し訳ありません)
フレームパラメータに任意の値を使用すると、http:// supercito.com.arページが読み込まれ、_selfを使用しない限りウィンドウがポップアップになります。
問題は、この新しいウィンドウがポップアップに変わる部分が見えないことです。おそらく、ロードするjqueryファイルに隠されています。私を殴る。チャールズにも確認しました。誰かアイデアがあれば教えてください。やってみます。
お役に立てれば。
これは私の最初の投稿です:)

編集:
より良いテストのために変更をアップロードしました。
これで、メインURLも変更できます。

stop();
getURL (_root.main + _root.web, _root.marco);


Nº2
を編集 それはフラッシュです!
新しい設定では、任意のURLを試すことができ、ターゲットウィンドウが_selfまたは_topでない限り、ポップアップになります。つまり、Chromeはそれをポップアップとして解釈しますが、IEはそれを読み取ります。 _blankウィンドウとして。
私にはバグのように見えます。

于 2012-06-08T02:59:21.403 に答える
1

Flashから新しいブラウザウィンドウを開く方法はいくつかあります(HTMLページの助けを借りずに): http: //helpx.adobe.com/flash-player/kb/create-pop-browser-windows-flash.html

于 2012-06-03T18:32:24.917 に答える
1

それが可能かどうかはわかりません。

最近のブラウザにはかなり強力なポップアップブロッカーがあり、ほとんどの場合、ユーザーの操作がない場合は新しいウィンドウ/タブを開くことができません。

あるブラウザをだましてみても、別のブラウザ/OSでは動作しない可能性があります。

ところで、ページにJSがなく、HTMLを編集できない場合は、「疑似プロトコル」を使用してFlashから直接JSを実行できます。

var req:URLRequest = new URLRequest('javascript:void(alert('This is called from Flash'))');
navigateToURL(req);

したがって、理論的には、HTMLページに非常に複雑なJSを「注入」することができます。

于 2012-06-03T20:14:27.477 に答える
1

まず、window.top.documentを使用していることを確認する必要があります。そこからウィンドウを開いてみてください。ウィンドウハンドルがnullの場合は、100%iframeを開きます。

    /**
     *  @public
     */
    public function JSTest():void {

        ExternalInterface.call('eval', [

            "window.createFrame = function() {",
                "var doc                = window.top.document;",
                "var ifrm               = doc.createElement('IFRAME');",
                "ifrm.style.position    = 'absolute';",
                "ifrm.style.left        = '0';",
                "ifrm.style.top         = '0';",
                "ifrm.style.width       = '100%';",
                "ifrm.style.height      = '100%';",
                "ifrm.setAttribute('src', 'http://vimeo.com');",
                "doc.body.appendChild(ifrm);",
            "}",

            // try opening window, otherwise, open an iframe
            "if (!window.open('http://www.vimeo.com', '_top')) {",
                "window.createFrame();",
            "}"

        ].join('\n'));

    }
于 2012-06-04T18:31:56.023 に答える