我正在尝试在 iPhone 上查看时运行某种图像格式,而在其他情况下运行一些 flash 视频
var uagent = navigator.userAgent.toLowerCase();
if (uagent.search("iphone") > -1){
document.write("<img src=http://www.demiads.com/images/bc-1300119669-722.gif />"); }
else{
document.write("<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0 width=728 height=90 id=lang align=middle style=margin-left:3px;>
<param name=allowScriptAccess value=sameDomain />
<param name=allowFullScreen value=false />
<param name=movie value=http://koha.net//repository/reklamat/17_05_12_131575_koha.net_hej_reveal_675x88px.swf />
<param name=quality value=high />
<param name=bgcolor value=#ffffff />
<param name=wmode value=transparent />
<embed src=http://koha.net//repository/reklamat/17_05_12_131575_koha.net_hej_reveal_675x88px.swf
quality=high WMODE=transparent bgcolor=#ffffff width=728 height=90
name=ifm_al align=middle allowScriptAccess=sameDomain
allowFullScreen=false type=application/x-shockwave-flash
pluginspage=http://www.macromedia.com/go/getflashplayer />
</object>");
}
测试时效果很好,但广告系统没有在发布商网站上显示它。我检查了一个网站的源代码,我注意到每当找到 " 或 ' 时都会添加一个 \,从而使其不起作用!我试图尽量减少 " 或 ' 的使用,但这是我所能做到的去。有没有办法解决这个问题?先感谢您。
结果
if (uagent.search(\"iphone\") > -1){
document.write(\"<img src=http://www.demiads.com/images/bc-1300119669-722.gif />\"); }
else{
document.write(\"<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0 width=728 height=90 id=lang align=middle style=margin-left:3px;>
<param name=allowScriptAccess value=sameDomain />
<param name=allowFullScreen value=false />
<param name=movie value=http://koha.net//repository/reklamat/17_05_12_131575_koha.net_hej_reveal_675x88px.swf />
<param name=quality value=high />
<param name=bgcolor value=#ffffff />
<param name=wmode value=transparent />
<embed src=http://koha.net//repository/reklamat/17_05_12_131575_koha.net_hej_reveal_675x88px.swf
quality=high WMODE=transparent bgcolor=#ffffff width=728 height=90
name=ifm_al align=middle allowScriptAccess=sameDomain
allowFullScreen=false type=application/x-shockwave-flash
pluginspage=http://www.macromedia.com/go/getflashplayer />
</object>\");
}