我经营一个电子商务网站。在我们的订单确认页面上,我们运行第三方 javascript,它会自动执行可选调查。
调查的问题在于执行需要 20 秒,并且会减慢关键的“订单完成”页面的呈现速度。
我想阻止加载此脚本,直到客户单击按钮。
理想情况下,页面将在不执行脚本的情况下加载。页面上会出现一些文字,“您想参加调查吗?如果是,请单击此处。” 然后页面会调用第三方javascript来执行调查代码。
下面是第三方javascript。第一个脚本标签只收集变量,第二个脚本标签实际运行调查代码。
<script language="JavaScript">
// var passin_x =; //comment out to default center or adjust horizontal position by pixel
// var passin_y =; //comment out to default center or adjust vertical position by pixel
var orderId='@@order_id@@';
// var z_index =; //default 9995
var cartTotal='@@purchase_total@@';
// var billingZipCode=;
// Pass up to 5 products from customer shopping cart
//var productsPurchased= 'URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=|URL=^SKU=^GTIN=^PRICE=';
</script>
<script type="text/javascript" src="https://eval.bizrate.com/js/pos_xxxxx.js">
</script>
如何在点击事件后动态加载脚本?