我无法将query_enc
var值从第一个<script>
标记传递到第二个<script>
标记src
这是我的代码 -
<script>
var query_enc = "";
var query = "%inputParams.query%";
if !( stringStartsWith(query, "%" && stringEndsWith(query, "%")
{
query_enc = encodeURIComponent(query);
}
buildUrl(query_enc);
</script>
<script src="http://keyword.monfuel.com/sponsored.js?q='+query_enc+'&url=%inputParams.clientSiteUrl%&height=250&sp1=sitefuel&sp2=Latestmotorcyceles&sp3=BB&padding=7"></script>
这是结果
<script src="http://keyword.monfuel.com/sponsored.js?q=**'+query_enc+'**&url=http://latestmotorcycles.com/&height=250&sp1=sitefuel&sp2=Latestmotorcyceles&sp3=BB&padding=7"></script>
答案 0 :(得分:0)
你可以使用PHP或服务器端语言,但如果你注定要注定JavaScript。您应该动态创建元素(动态)。
var s = document.createElement( 'script' );
s.setAttribute( 'src', 'http://keyword.monfuel.com/sponsored.js?q='+query_enc+'&url=%inputParams.clientSiteUrl%&height=250&sp1=sitefuel&sp2=Latestmotorcyceles&sp3=BB&padding=7');
document.head.appendChild(s);