What does mean?

前端 未结 5 1987
生来不讨喜
生来不讨喜 2021-01-30 07:03

In my html page, I see a link whose \'view source\' code is as below :


I see a valid link when I hover my m

相关标签:
5条回答
  • 2021-01-30 07:52

    Javascript may be hooking up to the click-event of the anchor, rather than injecting any href.

    For example, jQuery:

    $('a.view').click(function() { Alert('anchor without a href was clicked');});
    

    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)

    0 讨论(0)
  • 2021-01-30 07:58

    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.

    0 讨论(0)
  • 2021-01-30 08:02

    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.

    <a href="#" class="view">
    

    The

    href="#"
    

    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:

    <a href="#news">Go to news</a>
    

    will take you to wherever you have the

    <a name="news"></a>
    

    code. So if you specify # without any name like in your case, the link leads nowhere.

    The

    class="view"
    

    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:

    <script type="text/javascript"> bla bla bla </script>
    

    or

    <script> bla bla bla </script>
    

    and then search for any reference to your "view"-class. An included javascript file can look something like this:

    <script type="text/javascript" src="include/javascript.js"></script>
    

    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.

    0 讨论(0)
  • 2021-01-30 08:04

    The href is probably generated in a javascript function. For example with jQuery:

    $(function() {
        $('a.view').attr('href', 'http://www.google.com');
    });
    
    0 讨论(0)
  • 2021-01-30 08:05

    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.

    0 讨论(0)
提交回复
热议问题