SWF如何将内容注入网页

aps*_*nce 7 html javascript security actionscript-3

通过嵌入以下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">
Run Code Online (Sandbox Code Playgroud)

如果代码嵌入到框架中,则不会创建新选项卡,而是修改框架以添加html页面.

编辑:页面上没有JAVASCRIPT.

SWF文件如何执行此操作?(将内容注入网页)?

Tib*_*tan 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文件的object标记中,设置以下参数: <param name="allowScriptAccess" value="always" />
  • 在SWF文件中,添加以下ActionScript: flash.system.Security.allowDomain(sourceDomain)

我测试了上述所有内容,它在我的浏览器上运行良好:Google Chrome 19,Internet Explorer 8,Firefox 12.

按照你的要求,文档方面没有javascript :)