Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:03:57+00:00 2026-06-13T16:03:57+00:00

There is a similar popular question regarding whether to use # or javascript:void(0) in

  • 0

There is a similar popular question regarding whether to use # or javascript:void(0) in the href attribute.

What’s the preferred way to do this in the Dart community? If I use the hash, the browser scrolls to the top, but with javascript:void(0) it looks ugly not just because it is but also because we are doing Dart and not JavaScript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:03:58+00:00Added an answer on June 13, 2026 at 4:03 pm

    There is this a horrible myth on the web that we should use # or javascript:void(0). Please, do not do this. The only case when you are allowed to use # is when you want to scroll to different sections of the page.

    If you don’t want the link to have the default behavior of taking you somewhere, either don’t use a link or take the entire href-attribute away:

    test.html

    <!DOCTYPE html>
    <html>
      <body>
        <a id="foo">Do something</a>
    
        <script type="application/dart" src="test.dart"></script>
        <script src="https://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
      </body>
    </html>
    

    Next we have to override some default styles to make sure we get the hand-cursor and underlining, because browsers tend to remove those when you don’t have a href-attribute:

    styles.css

    a {
        cursor: pointer;
        text-decoration: underline;
    }
    
    a:hover {
        text-decoration: none;
    }
    

    Lastly our Dart code that does whatever you want it to do:

    test.dart

    import 'dart:html';
    
    void main() {
      AnchorElement a = query('#foo');
      a.on.click.add((e) {
        print('Clicked! Do something.');
      });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is similar to this question . I asked Why? to the most popular
There are similar questions to this, but I don't think anyone has asked this
There are similar questions out there on this topic, such as When can I
Is there a way to create the server side of something similar to S3,
There are already so many questions asked about this already. One popular answer is
There was a similar question asked here three years ago, but I want to
Are there any libraries for in-browser javascript that provide the same flexibility/modularity/ease of use
I suppose this might be similar to this question , but I'm wondering if
This question is similar to the Remove html character entities in a string question
There are many applications to recognize similar faces. The most popular is Picasa .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.