开发者

js file - insert window.location into appended html

I have a js file that is appending html. For one specific relative link, I need the link to be https. I'm assuming I would set a var, but I'm unsure how to insert it into the appended html within the js file.

$('#emailUpdates').append('<div class="head-popin ac-popin"><ul><li><a href="/webapp/wcs/stores/servlet/LLBLoginRedirectCmd?feat=ln&gUrl=ShowMAOAPLogin&lUrl=LLBOAPCouponLPAccessCheck&pgType=MA&storeId=1&catalogId=1&langId=-1">Coupon Lookup</a>&l开发者_JAVA技巧t;/li></ul></div>').css({
                    "padding-left": "78px"
                });

So the link above, I want the above to be something like https:// +window.location.hostname +/webapp/wcs/stores/servlet/LLBLoginRedirectCmd?feat=ln&gUrl=ShowMAOAPLogin&lUrl=LLBOAPCouponLPAccessCheck&pgType=MA&storeId=1&catalogId=1&langId=-1

But I'm unsure how to get that effect in this example.

thanks


Something like this?

var href = 'https://' + window.location.hostname + '/webapp/wcs/stores/servlet/LLBLoginRedirectCmd?feat=ln&gUrl=ShowMAOAPLogin&lUrl=LLBOAPCouponLPAccessCheck&pgType=MA&storeId=1&catalogId=1&langId=-1';

var html = '<div class="head-popin ac-popin"><ul><li><a href="' + href + '">Coupon Lookup</a></li></ul></div>';

$('#emailUpdates').append(html).css({
    "padding-left": "78px"
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜