当网页显示“Choisissez la finition”消息时,我需要在我的网站上激活第三方标签
显示此消息的div是
<div id="vw_dbs_ihdcc_TrimSelector" class="container containerColQuarter"><h2>Choisissez la finition</h2>
我尝试过类似的东西
function (session, cb){window.addEventListener("hashchange", function()
{
if(document.location.hash.indexOf("carimage") > -1)
{
var len2 = jQuery("h2:contains('Choisissez la finition')").length;
if (len2 > 0)
{
cb();
}
}
});
}
任何建议,帮助?
非常感谢,
答案 0 :(得分:0)
您需要的是以下内容。
function doSomething(session, cb){
if(location.hash.indexOf("carimage") > -1) {
var len = $("h2:contains('Choisissez la finition')").length;
if (len) {
cb();
}
}
});
//Define your callback function
function mycb() {
alert ("I am a callback function");
}
//Bing event on hashchange using jQuery as you anyway have it.
$(window).on("hashchange", function() {
//Call your function with params
doSomething("yourSession", mycb);
});