gpt4 book ai didi

javascript - 如何在网页中找到 JavaScript 源代码?

转载 作者:太空宇宙 更新时间:2023-11-04 16:04:51 26 4
gpt4 key购买 nike

我想检查一个 JavaScript 函数的源代码 web page

在 Firefox Inspector 中,我点击了 enter image description here

我明白了:

<a href="/thread/7629335?start=75&amp;tstart=0" title="last" onclick="jspaginate.init('last', '6'); return false;" class="js-pagination-next j-paginate-last">last</a>

我想找到jspaginate.init 的源代码。我单击了“调试器”选项卡,但没有看到 jspaginate.init。来源应该在页面上的某个地方,不是吗?

我在 Mac OS 10.10.5 中运行 Firefox 48.0。我在督察里 enter image description here

最佳答案

在firefox中打开需要的页面,按F12打开开发者工具。在“调试器”选项卡中按 ctrl + shift + F(在文件中搜索)并搜索“jspaginate”。它将向您显示包含该词的所有文件。

Firefox Developer Tools - Search

Firefox Developer Tools: search for files with the debugger (Video)


或者使用 FireBug 不再支持 Firefox >57*

安装 firebug ,激活它,也激活脚本面板,然后查找 jspaginate 对象。在一个 js 文件中你会发现它:

var jspaginate = {
data:{},
loading: false,
init: function(action, last){
var view = this,
target, current;
if(this.loading !== true){
view.loadingSequence();
if(action === 'first'){
target = 0;
view.update(target, 0);
}else if(action === 'prev'){
current = parseInt(view.data.pageIndex)-1;
target = (current)*view.data.range;
view.update(target, current);
}else if(action === 'next'){
current = parseInt(view.data.pageIndex)+1;
target = (current)*view.data.range;
view.update(target, current);
}else if(action === 'last'){
current = parseInt(last)-1;
target = (current)*view.data.range;
view.update(target, current);
}
}
},
update: function(target, current){
this.data.pageIndex = current;
this.pushState(target, current);
this.getData(target);
},
pushState: function(target, current){
var state = { 'page_id': current, 'user_id': 2 },
title = 'Page'+ current,
url = '?start='+target+'&tstart=0';
history.pushState(state, title, url);
},
loadingSequence: function(){
this.loading = true;
$j('.j-pagination').append('<div class="j-loading-big"><span></span></div>');
$j('.all-replies-container').css('opacity','.5');
},
removeLoading: function(){
$j('.j-loading-big').remove();
$j('.all-replies-container').css('opacity','1');
this.loading = false;
},
updateUI: function(data){
$j('.all-replies-container').html(data);
$j('html, body').animate({
scrollTop: ($j(".all-replies-container").offset().top -180)
}, 800);

this.removeLoading();
},
getData: function(target){
var view = this,
tId = (this.data.threadId).split('/')[2],
urlString = jive.app.url({path:'/inline-thread.jspa?thread='+tId+'&start='+target+'&tstart=0'});
$j.ajax({
url: urlString,
cache: true,
async: true,
type:'POST',
dataType : 'html'
}).success(function(data) {
view.updateUI(data);
}).error(function(data) {
console.log(data);
});
}
}
;

关于javascript - 如何在网页中找到 JavaScript 源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38935941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com