I'd like to load a couple of Amazon widgets with different search terms and highlight some results.
The problem is, how can I know when both widgets are loaded? I've tried many different snippets (with load, ready, etc...) I've found here and there, but without success.
Basically, when loaded, each widget's content is within an "ad unit" DIV (..._adunit_0 and ..._adunit_1), which contains another DIV, and inside that one there's an IFRAME. Both DIVs have IDs, but no the IFRAMEs, in case that matters.
<div id="amzn_assoc_ad_div_adunit_0">
<div id="__mobileAssociatesSearchWidget_adunit_0" class="__mobile-associates-search-widget">
<iframe>search results</iframe>
</div>
</div>
Here's the code that loads the 2 widgets: https://jsfiddle.net/rz8ytfxd/
<html>
<body>
<script type='text/javascript'>
amzn_assoc_ad_type = 'responsive_search_widget';
amzn_assoc_tracking_id = '';
amzn_assoc_marketplace = 'amazon';
amzn_assoc_region = 'DE';
amzn_assoc_placement = '';
amzn_assoc_search_type = 'search_widget';
amzn_assoc_width = 'auto';
amzn_assoc_height = 'auto';
amzn_assoc_default_search_category = '';
amzn_assoc_default_search_key = 'lonely planet ukraine'
amzn_assoc_theme = 'light';
amzn_assoc_bg_color = 'FFFFFF';
</script>
<script src='//z-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1&Marketplace=DE'></script>
<script type='text/javascript'>
amzn_assoc_ad_type = 'responsive_search_widget';
amzn_assoc_tracking_id = '';
amzn_assoc_marketplace = 'amazon';
amzn_assoc_region = 'DE';
amzn_assoc_placement = '';
amzn_assoc_search_type = 'search_widget';
amzn_assoc_width = 'auto';
amzn_assoc_height = 'auto';
amzn_assoc_default_search_category = '';
amzn_assoc_default_search_key = 'lonely planet poland'
amzn_assoc_theme = 'light';
amzn_assoc_bg_color = 'FFFFFF';
</script>
<script src='//z-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1&Marketplace=DE'></script>
</body>
</html>
Any help would be greatly appreciated. I don't mind if a solution requires jQuery or any other library.
Michael
[I'll probably post another question just for that, but just in case... Do you have any idea why the spaces in the search term are replaced with %20 (thus giving bad results) despite it being the code exactly as copied from Amazon? Can something be done about that?]