2017-05-02 13 views
0

私は下のjsにいくつかの行を追加する必要があります。 私がしたいのは、URL "%% cta %%"の末尾に#idを追加することです。 誰かが私を助けることができますか?どうもありがとう!URLの末尾に広告のアンカー

thisthing.replaceData = function (thisTemplate, htmlList, htmlOverlayer, dataJs, indexLi) { 
    //thisTemplate = thisTemplate.replace('%%img%%', '/B2C/ResourcesWebRevise/booking/thisthing/custom/' + dataJs + '.jpg'); 
    thisTemplate = thisTemplate.replace('%%title%%', thisthingData.title); 
    thisTemplate = thisTemplate.replace('%%desc%%', thisthingData.desc); 
    thisTemplate = thisTemplate.replace('%%cta%%', thisthingData.cta); // bridge cta 
    thisTemplate = thisTemplate.replace('%%list%%', htmlList); 
    thisTemplate = thisTemplate.replace('%%overlayer%%', htmlOverlayer); 
    thisthing.print(thisTemplate, dataJs, indexLi); 
} 
+0

は、だから、この 'HTTPのようなURLたい:// foo.bar /データ/ CTAの#ID/MoreData'または'のhttp://のようなfoo.bar /データ/ CTA/MOREDATA番号のid' – Oen44

+0

何かthis /B2C/ResourcesWebRevise/booking/thisthing/custom/page.aspx#id –

+0

それから私の答えをチェックしてください。 – Oen44

答えて

1

希望が必要です。 +=を使用して文字列の最後に追加するだけです。

thisthing.replaceData = function(thisTemplate, htmlList, htmlOverlayer, dataJs, indexLi) { 
    //thisTemplate = thisTemplate.replace('%%img%%', '/B2C/ResourcesWebRevise/booking/thisthing/custom/' + dataJs + '.jpg'); 
    thisTemplate = thisTemplate.replace('%%title%%', thisthingData.title); 
    thisTemplate = thisTemplate.replace('%%desc%%', thisthingData.desc); 
    thisTemplate = thisTemplate.replace('%%cta%%', thisthingData.cta); // bridge cta 
    thisTemplate = thisTemplate.replace('%%list%%', htmlList); 
    thisTemplate = thisTemplate.replace('%%overlayer%%', htmlOverlayer); 
    thisTemplate += "#id"; // Pretty simple 
    thisthing.print(thisTemplate, dataJs, indexLi); 
} 
+0

ご協力ありがとうございます!このようにして、すべての%% name %%に+ #idを追加しますか?私がしなければならないのは、idを%% cta %%にだけ追加することです。申し訳ありません、多分私はひどく説明しました –

+0

あなたが提供したコードについて何を求めているのかは不明です。 「%% cta %%のみ」とはどういう意味ですか?この機能が何を印刷するか教えていただけますか?出力例。 – Oen44

+0

この関数はリンクをここに表示します:アンカーリンクを追加する必要があります –

関連する問題