Spectoos on "[Plugin: Autoptimize] Non working embed code"

ساخت وبلاگ

Hi Frank,
I'd like to use this embed code on my site, but it breaks ...

<iframe id="intercom_map_iframe" src="" frameborder="0" height="600" width="800"></iframe><script>(function(){var d = document.getElementById('intercom_map_iframe').contentWindow.document;d.open().write('<body onload="document.location.replace('https://share.intercom.io/mnXeOFKMi-lg?embed=true')"></body>');d.close();})();</script>

Please check http://www.spectoos.com/map

Any ideas?

Thank you,
Guy.

https://wordpress.org/plugins/autoptimize/

you could wrap that entire block in noptimize-tags (see FAQ) or add intercom_map_iframe to the comma-separated JS optimization exclusion list?

frank

Thanks Frank,
I've added intercom_map_iframe, to the comma-separated list but it still doesn't work ...

Cheers,
Guy.

well, then you could go for the noptimize-approach? :)

OK, <!-- noptimize --> solved it!

Cheers,
Guy.

I see

11:57:30.484 SyntaxError: unterminated string literal map:65:105

on my browser's console, so that confirms the JS has been excluded from optimization, but there seems to be a problem with it?

ah ... just a sec, think I know what is happening ...

ok, so AO injects the js before the </body>-tag. your JS has that tag in it, so AO injects the JS inside your code.

so, try changing it into:

<iframe id="intercom_map_iframe" src="" frameborder="0" height="600" width="800"></iframe><script>(function(){var d = document.getElementById('intercom_map_iframe').contentWindow.document;
d.open().write('<body onload="document.location.replace('https://share.intercom.io/mnXeOFKMi-lg?embed=true')"></bo'+'dy>');d.close();})();</script>

so </body>'); becoming </bo'+'dy>');

frank

ah, didn't see you earlier message, noptimize FTW! :-)

Spectoos
Member
Posted 1 minute ago #

:)
Thanks Frank for your help!

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 362 تاريخ : چهارشنبه 13 مرداد 1395 ساعت: 23:15