具有此代码:
//Helpful method for getting variables from a url. returns
//null if not found. Decodes any URL encoded vars and also decodes
//any html entities
function getQueryVariable(url,variable) {
var query = url;
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
var decoded = $('<div/>').html(decodeURIComponent(pair[1])).text();
return decodeURIComponent(decoded);
}
}
return null;
}
$(document).ready(function() {
//If the doclick parameter is specified, this means
//the user probably middle-mouse clicked the link.
//In this case, do the click immediately
if (window.location.search.indexOf("doclick") != -1) {
doQueryAndDisplay(getQueryVariable(window.location.search,"linkid"),
getQueryVariable(window.location.search,"landingpage") != null,
getQueryVariable(window.location.search,"furl"));
}
//When the anchor tag is clicked,
//we will do an ajax query to see
//if the asset is gated
$(".gated-link").click(function(e) {
e.preventDefault();
//Pass the id of the link to the doQuery function, along with the
//channel id,
doQueryAndDisplay(getQueryVariable($(this).attr("href"),"linkid"),
getQueryVariable($(this).attr("href"),"landingpage") != null,
getQueryVariable($(this).attr("href"),"furl"));
});
});
它是网站的一部分。
如何找到何时或在哪个页面上触发功能/功能?
如何在页面上触发它?
该JS代码包含在带有脚本标记的JS文件的页面中。
有人可以指导吗??
我正在调试此问题,并希望将值传递给pair [1]
我希望这是问这个问题的正确地方。