在我的 html 页面中,我看到一个链接,其“查看源代码”代码如下:
<a href="#" class="view">
当我将鼠标悬停在其上时,我看到一个有效的链接,当我单击它时,它起作用了。但我无法找到该 URL 的生成位置和方式。我发现类 a.view 是在其中一个 CSS 中定义的,但在页面源代码中找不到 URL。有人可以帮我找到这个 URL 吗?
In my html page, I see a link whose 'view source' code is as below :
<a href="#" class="view">
I see a valid link when I hover my mouse on it and when I click it, it works. But I am not able to find where and how this URL gets generated. I found the class a.view being defined in one of the CSS, but couldn't find the URL in the page source.. Can somebody help me out on whr i can find this URL ?
发布评论
评论(5)
我也想回答一下,用与其他人有点不同的方式解释同样的事情。我相信您知道其中大部分内容,但它可能对其他人有帮助。
该
部分是确保链接本身不会指向任何地方的常用方法。 # 属性用于创建指向同一文档中其他部分的链接。例如,单击此类链接:
将带您前往拥有
代码的任何地方。因此,如果您像您的情况一样指定 # 而没有任何名称,则该链接将无处可去。
该
部分为其提供了 CSS 或 javascript 可以使用的标识符。在 CSS 文件(如果有的话)中,您将找到所有标记有“view”类的元素的特定样式程序。
要找出指定 URL 的位置,我将查看 javascript 代码。它可以直接写入同一文档中,也可以包含在另一个文件中。
在源代码中搜索类似以下内容:
或
然后搜索对“view”类的任何引用。包含的 javascript 文件可能如下所示:
在这种情况下,打开“include”文件夹下的 javascript.js 并在该文件中搜索。最常见的是,包含内容放置在
和
之间或靠近
标记。
查找链接的更快方法是搜索它所转到的实际链接。例如,如果您被定向到 http://www.google.com/search?q=html 当您单击它时,在您的网络项目中的所有文件中搜索“google.com”或其他内容,只需记住包含的文件即可。
在许多文本编辑器中,您可以一次打开所有文件,然后在所有文件中搜索某些内容。
I felt like replying as well, explaining the same thing as the others a bit differently. I am sure you know most of this, but it might help someone else.
The
part is a commonly used way to make sure the link doesn't lead anywhere on it's own. the #-attribute is used to create a link to some other section in the same document. For example clicking a link of this kind:
will take you to wherever you have the
code. So if you specify # without any name like in your case, the link leads nowhere.
The
part gives it an identifier that CSS or javascript can use. Inside the CSS-files (if you have any) you will find specific styling procedures on all the elements tagged with the "view"-class.
To find out where the URL is specified I would look in the javascript code. It is either written directly in the same document or included from another file.
Search your source code for something like:
or
and then search for any reference to your "view"-class. An included javascript file can look something like this:
In that case, open javascript.js under the "include" folder and search in that file. Most commonly the includes are placed between
<head>
and</head>
or close to the</body>
-tag.A faster way to find the link is to search for the actual link it goes to. For example, if you are directed to http://www.google.com/search?q=html when you click it, search for "google.com" or something in all the files you have in your web project, just remember the included files.
In many text editors you can open all the files at once, and then search in them all for something.
href 可能是在 javascript 函数中生成的。例如使用 jQuery:
The href is probably generated in a javascript function. For example with jQuery:
JavaScript 可能会连接到锚点的点击事件,而不是注入任何 href。
例如,jQuery:
当然,javascript 可以通过单击事件执行任何操作 - 例如导航到其他页面(在这种情况下,href 从未设置,但锚点的行为仍然像设置一样)
Javascript may be hooking up to the click-event of the anchor, rather than injecting any href.
For example, jQuery:
Of course, the javascript can do anything it wants with the click event--such as navigate to some other page (in which case the href is never set, but the anchor still behaves as though it were)
不要忘记查看 Javascript。我的猜测是,当您单击链接时,会执行自定义 Javascript 代码,并且正是该 Javascript 生成 URL 并导航到该 URL。
Don't forget to look at the Javascript as well. My guess is that there is custom Javascript code getting executed when you click on the link and it's that Javascript that is generating the URL and navigating to it.
它可能适用于 Javascript。当您单击该链接时,不会发生任何事情,因为它指向当前站点。然后 JavaScript 将加载一个窗口或一个 url。它在 AJAX Web 应用程序中被大量使用。
It probably works with Javascript. When you click the link, nothing happens because it points to the current site. The javascript will then load a window or an url. It's used a lot in AJAX web apps.