FAQ Topic - I have <a href="javascript:somefunction()"> what ... ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FAQ server

    #1

    FAQ Topic - I have <a href="javascript:somefunction()"> what ... ?

    -----------------------------------------------------------------------
    FAQ Topic - I have <a href="javascrip t:somefunction( )"what
    .... ?
    -----------------------------------------------------------------------

    Whatever the rest of your question, this is generally a very bad
    use of the javascript pseudo protocol. It was designed so that a
    function could return a new page. For example:
    ` javascript:"<p> Hello</p>" `.
    Using it simply to call a function when a link is clicked causes
    an error in user agents that do not support javascript, or have
    javascript disabled. Instead, use
    ` <a href="something .html" onclick="somefu nction();return false"`
    where something.html is a meaningful alternative. Alternatively,
    place the onclick event on another element so that users without
    JavaScript aren't even aware that it does anything.

    Every year brings new mistakes. In 2002, several of the worst mistakes in Web design related to poor email integration. The number one mistake, however, was lack of pricing information, followed by overly literal search engines.



    ===
    Postings such as this are automatically sent once a day. Their
    goal is to answer repeated questions, and to offer the content to
    the community for continuous evaluation/improvement. The complete
    comp.lang.javas cript FAQ is at http://jibbering.com/faq/index.html.
    The FAQ workers are a group of volunteers.

  • marss

    #2
    Re: FAQ Topic - I have &lt;a href=&quot;java script:somefunc tion()&quot;&gt ; what ... ?

    Whatever the rest of your question, this is generally a very bad
    use of the javascript pseudo protocol. It was designed so that a
    function could return a new page. For example:
    ` javascript:"<p> Hello</p>" `.
    There are many things in the world that are used in a different way
    than they were designed for. Only about 4% of users have javascript
    disabled, probably a half of them are bots.

    Comment

    • Richard Cornford

      #3
      Re: FAQ Topic - I have &lt;a href=&quot;java script:somefunc tion()&quot;&gt ; what ... ?

      marss wrote:
      >
      >Whatever the rest of your question, this is generally a very bad
      >use of the javascript pseudo protocol. It was designed so that a
      >function could return a new page. For example:
      >` javascript:"<p> Hello</p>" `.
      >
      There are many things in the world that are used in a different
      way than they were designed for.
      And a significantly proportion of those usages are a bad idea.
      Only about 4% of users have javascript
      disabled, probably a half of them are bots.
      How could you tell (especially given the "self-fulfilling" nature of the
      consequences of people taking web statistics seriously)?

      But overall, what is your point?

      Richard.

      Comment

      • marss

        #4
        Re: FAQ Topic - I have &lt;a href=&quot;java script:somefunc tion()&quot;&gt ; what ... ?


        Richard Cornford wrote:
        Only about 4% of users have javascript
        disabled, probably a half of them are bots.
        >
        How could you tell (especially given the "self-fulfilling" nature of the
        consequences of people taking web statistics seriously)?
        Figures are taken here:

        But overall, what is your point?
        1.<a href="javascrip t:somefunction( );" ...
        2.<a href="something .html" onclick="somefu nction();return false">
        First variant looks more user friendly because user have a right to
        know what will happen when he will click on a link. IMHO.

        All ASP.Net are build on using <a href="javascrip t:somefunction( )...
        Are you sure that only silly developers work in Microsoft?

        This topic is out-of-date in my opinion. Without offence.
        Regards, Mykola

        Comment

        • Richard Cornford

          #5
          Re: FAQ Topic - I have &lt;a href=&quot;java script:somefunc tion()&quot;&gt ; what ... ?

          marss wrote:
          Richard Cornford wrote:
          >
          Only about 4% of users have javascript
          disabled, probably a half of them are bots.
          >>
          >How could you tell (especially given the "self-fulfilling"
          >nature of the consequences of people taking web statistics
          >seriously)?
          >
          Figures are taken here:
          http://www.thecounter.com/stats/2007/June/javas.php
          And where is the link to the page that explains the details of the
          statistics gathering process in the detail that allows the reader to
          judge whether, and if so how, effects such as self-biasing and the
          fundamental limitations on statistics gathering inherent in HTTP, have
          been addressed? Statistics are not any less bogus if you employ a
          machine to turn garbage data into them than when you make them up off
          the top of your head.

          It is also questionable whether a link should be something that triggers
          an action that is not navigation (or conceptually equivalent to
          navigation). If the side effect alone is the desired outcome the more
          appropriate elements would be <NPUT type=buttonand <BUTTON
          type=button>, neither of which would be expected so show anything in the
          status bare at all.
          >But overall, what is your point?
          >
          1.<a href="javascrip t:somefunction( );" ...
          2.<a href="something .html" onclick="somefu nction();return false">
          First variant looks more user friendly because user have a right to
          know what will happen when he will click on a link. IMHO.
          In what sense does the user "know what will happen" when they see
          'javascript:som efunction();' in their status bar? Even the tiny minority
          who know what javascript is would not know what 'somefunction' was going
          to do without seeing its source code and understanding the actions coded
          in it.
          All ASP.Net are build on using <a href="javascrip t:somefunction( )...
          That would be extremely foolish given the well-known and generally
          undesirable, side effects of executing javascript pseudo-protocol HREFs
          on Microsoft browsers prior to IE7.
          Are you sure that only silly developers work in Microsoft?
          Increasingly. An impression reinforced whenever I visit MSDN and get
          that "parentElement. parentElement is null or not an object" error (an
          error which means that MS are employing people who are writing IE only
          code (the easiest client-side programming task going) and still cannot
          write code that does not error all over the place).
          This topic is out-of-date in my opinion.
          <snip>

          Not until IE6 (and all the earlier versions of MS's browser (plus the
          less common browsers that took the exaction of javascript
          pseudo-protocol HREFs as navigation and so went into an unpredictable
          'pending' state following their use)) have gone out of existence.

          Richard.

          Comment

          • marss

            #6
            Re: FAQ Topic - I have &lt;a href=&quot;java script:somefunc tion()&quot;&gt ; what ... ?


            Richard Cornford wrote:
            And where is the link to the page that explains the details of the
            statistics gathering process in the detail that allows the reader to
            judge whether, and if so how, effects such as self-biasing and the
            fundamental limitations on statistics gathering inherent in HTTP, have
            been addressed? Statistics are not any less bogus if you employ a
            machine to turn garbage data into them than when you make them up off
            the top of your head.

            I agree with you somewhat. But this data rather similar to my own
            experience. Three simple questions:
            1.Do you use browser with disabled javascript while surf the web?
            2.How many of your friends or associates use browser with disabled
            javascript while surf the web?
            3.Did you ever use browser with disabled javascript?
            My answers:
            1. No
            2. 0
            3. Yes, long time ago, when was starting to use internet and was
            afraid of my own shadow not to mention javascript. And a few time for
            testing. Quite keep within 4%.
            Whether was I useful as visitor/buyer/customer at the time of such
            browsing? I guess, no. Laboriousness of development of site that takes
            into account such type of users is not worthy of it.
            In what sense does the user "know what will happen" when they see
            'javascript:som efunction();' in their status bar? Even the tiny minority
            who know what javascript is would not know what 'somefunction' was going
            to do without seeing its source code and understanding the actions coded
            in it.
            At least he will known that javascript will be executed.
            Are you sure that only silly developers work in Microsoft?
            >
            Increasingly. An impression reinforced whenever I visit MSDN and get
            that "parentElement. parentElement is null or not an object" error (an
            error which means that MS are employing people who are writing IE only
            code (the easiest client-side programming task going) and still cannot
            write code that does not error all over the place).
            :). MSDN is another story. I guess it is older than many of the modern
            browsers and it is too large to be reworked. Although, maybe, it
            should be done.

            Regards,
            Mykola

            Comment

            • Richard Cornford

              #7
              Re: FAQ Topic - I have &lt;a href=&quot;java script:somefunc tion()&quot;&gt ; what ... ?

              marss wrote:
              >
              Richard Cornford wrote:
              >
              >And where is the link to the page that explains the details
              >of the statistics gathering process in the detail that allows
              >the reader to judge whether, and if so how, effects such as
              >self-biasing and the fundamental limitations on statistics
              >gathering inherent in HTTP, have been addressed? Statistics
              >are not any less bogus if you employ a machine to turn garbage
              >data into them than when you make them up off the top of your
              >head.
              >
              >
              I agree with you somewhat. But this data rather similar to
              my own experience.
              There are very good reasons to believe that all published/cited/made-up
              "web statistics" are a nonsense that can have no more than a
              coincidental relationship with reality. Here you are saying that you are
              inclined to believe some particular 'statistic' because it corresponds
              with your expectation (and so, by implication, would
              disbelieve/disregard another 'statistic' if it did not fit your
              expectations). With no objective/reasoned grounds for
              believing/disbelieving any 'web statistics' the criteria of assigning
              credibility based on a 'statistics' correspondence with a preconception
              may seem to be the best that is available, but it is still self-deluding
              nonsense and a very long way from grounds for making decisions.
              Three simple questions:
              1.Do you use browser with disabled javascript while surf the web?
              Depends on the browser I am using. It is only relatively recently that
              the proportion of embedded browsers with javascript support passed 50%.
              2.How many of your friends or associates use browser with disabled
              javascript while surf the web?
              What is an "associate" in this context? When I worked in financial
              services, a few years back now, at least two of our clients (who cannot
              be named for confidentiality reasons, but were banks and stock-broking
              companies) had javascript disabled on all the browsers on all their
              internal PCs. Maybe a bit paranoid of them, but a reality probably
              putting the number of people I have certainly known to have javascript
              disabled (at least while at work) in the area of 5-6 thousand (and these
              are the sort of well (often very well) paid individuals who most
              e-commerce endeavours would like as their customers).

              As to my friends; for some strange reason the majority of my friends are
              designers, developers, programmers and IT professionals, so not at all
              representative of the general public. They do, however, have a distinct
              tendency to use non-mainstream browser and browsers in non-default
              configurations.
              3.Did you ever use browser with disabled javascript?
              Yes, but not as often as I use browsers that do not have javascript to
              start with.
              My answers:
              1. No
              2. 0
              3. Yes, long time ago, when was starting to use internet and was
              afraid of my own shadow not to mention javascript. And a few
              time for testing. Quite keep within 4%.

              Whether was I useful as visitor/buyer/customer at the time of such
              browsing? I guess, no.
              So who was losing out; you or the people who could not take your money
              off you?
              Laboriousness of development of site that takes
              into account such type of users is not worthy of it.
              When I want an estimate of the cost of designing and creating a
              non-javascript dependent web site I will ask someone who knows how to
              create one, no someone how is looking for an excuse for never finding
              out. Much as when I want an estimate for the cost of piano tuning I
              would ask a piano tuner rather than the first individual I encountered
              with a spanner, no matter how willing he may be to undertake the job.
              >In what sense does the user "know what will happen" when they
              >see 'javascript:som efunction();' in their status bar? Even the
              >tiny minority who know what javascript is would not know what
              >'somefunctio n' was going to do without seeing its source code
              >and understanding the actions coded in it.
              >
              At least he will known that javascript will be executed.
              <snip>

              No he won't. You are thinking about web developers/designers again.
              Users are random members of the public who have absolutely no reason for
              even knowing what javascript is, let alone that it is capable of
              'executing', or the implications if its doing so.

              Richard.

              Comment

              Working...