简体   繁体   English

如何跟踪javascript文件请求的来源

[英]how to trace where a javascript file request is coming from

ok, i'm having so many problems with my custom template, it's not even funny ... 好的,我的自定义模板有很多问题,甚至都不好笑...

it's a custom template for joomla 3.x ... 这是joomla 3.x的自定义模板...

one problem which i'm trying to figure out is where is the missing javascript request coming from? 我想找出的一个问题是缺少的javascript请求来自哪里?

i've unpublished all modules, and even uploaded a new template with some alterations ... 我尚未发布所有模块,甚至上传了带有一些更改的新模板...

but it still persists! 但它仍然存在!

if you view source and click on the supposedly missing file, it shows up fine ... so, why in javascript console in Chrome does it keeps saying it's 404!!!!! 如果您查看源代码并单击所谓的丢失文件,它会很好显示...因此,为什么在Chrome的javascript控制台中它总是说404 !!

how do you figure how where the request is coming from? 您如何确定请求的来源?

also, I keep seeing this in view source but no idea where it's coming from ... 另外,我一直在视图源中看到它,但是不知道它是从哪里来的。

<script type="text/javascript">
    window.addEvent('load', function() {
new JCaption('img.caption');
   });
  </script>

EDIT ... 编辑...

to make it clear what file I'm talking about, it's this one: 为了弄清楚我在说什么文件,就是这个文件:

<script src="/social/services/templates/testingdifferentversion16/js/jquery-1.10.1.min.map.js" type="text/javascript"></script>

if you look at view source, you can access it fine. 如果您查看视图源,则可以很好地访问它。

if you see the error that it can't find it, hence the 404, the file is indeed missing. 如果看到找不到它的错误,因此出现404,则文件确实丢失。

that's why this post was written up, in order to find where that request is coming from. 这就是为什么这篇文章写起来,为了找到请求的来源。

hope this edit clears things up a bit. 希望此编辑可以使事情变得更简单。

EDIT 2 (as per morantis's request) 编辑2(根据morantis的要求)

##
# @package      Joomla
# @copyright    Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
# @license      GNU General Public License version 2 or later; see LICENSE.txt
##

##
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
##

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

## Mod_rewrite in use.

RewriteEngine On

## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects

##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##

# RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
# 
## End - Joomla! core SEF Section.

Check if there is a .htaccess file in the root directory and then check if there are mod_rewrite rules in that file. 检查根目录中是否有.htaccess文件,然后检查该文件中是否有mod_rewrite规则。 Many CMS packages use mod_rewrite to handle navigation through the site. 许多CMS软件包都使用mod_rewrite来处理整个站点的导航。 If you are using a program like Filezilla for FTP, then make sure that the program has "show hidden files" set in the options or you may not even see the .htaccess file. 如果您正在使用Filezilla for FTP之类的程序,请确保该程序在选项中设置了“显示隐藏文件”,否则您甚至可能看不到.htaccess文件。 if there is one, post its contents in your question. 如果有,请在您的问题中张贴其内容。

I quickly looked and yes, Joomla does use a mod_rewrite to control flow in the website and there are multiple errors that come from this. 我很快看了一下,是的,Joomla确实使用了mod_rewrite来控制网站中的流量,并且由此产生了多个错误。

http://forum.joomla.org/viewtopic.php?f=304&t=346374 http://forum.joomla.org/viewtopic.php?f=304&t=346374

This is a link that is not exactly on par with your question, but it does give you the idea of how things can get messed up using .htaccess. 这是一个与您的问题不完全相同的链接,但它确实使您了解如何使用.htaccess弄乱事情。 Give me a little more info and we will go from there. 给我更多信息,我们将继续。

Alright, if you trying to access this file then it will have to be put directly in the address bar. 好吧,如果您尝试访问此文件,则必须将其直接放在地址栏中。 If you look at the mod_rewrite rules, you will see that if the URL ends in a "/" or does not end in an extension, then it will have "index.php" added to the end of it. 如果查看mod_rewrite规则,您将看到,如果URL以“ /”结尾或不以扩展名结尾,那么它将在其末尾添加“ index.php”。

Does that make sense? 那有意义吗?

@user2730725 This drove me crazy a while back too! @ user2730725这也让我发疯了! That file is a .map and is for debugging purposes only. 该文件是.map文件,仅用于调试目的。 Turn off the setting that tries to retrieve it by opening Chrome Dev Tools, then Settings and in General there is a checkbox for Enable JS source maps. 通过打开Chrome Dev Tools,然后依次单击“设置”和“常规”中的“启用JS源映射”复选框,关闭尝试检索它的设置。 Unselect it. 取消选择。 Problem solved. 问题解决了。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM