DYNAMICALLY disable links with CSS?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Pugh

    #16
    Re: DYNAMICALLY disable links with CSS?

    Mark Johnson <102334.12@comp userve.com> wrote:[color=blue]
    >Steve Pugh <steve@pugh.net > wrote:
    >[color=green]
    >>Hang on. You have <a href="">text</a> and you've styled it so that it
    >>has a changing background on :hover, right?[/color]
    >
    >No. It just stays as text. But a couple of nested divisions before it,
    >just float to the left, and can contain a button and hover-button,
    >separately, for a single anchor tag which duplicates the href link.[/color]

    So you actually have two links to the same resource?
    [color=blue]
    >Some of my styles don't do that Typically it's display:none.
    >But one does. It's a very different look than the others.[/color]

    Yes, different styles produce different looks. You have two links to
    the same resource styled differently and you don't want one of them to
    be a link? So remove the <a> element from the second one.
    [color=blue]
    >So I wanted to
    >transfer the click, the link, over to the button, and away from the
    >text.[/color]

    It's impossible (well except by changing the document with JavaScript)
    to 'transfer' a link or anything like that. You seem to be implying
    that you've managed to do this 'transferring' somehow. Telling us how
    would maybe give us some indication of what on earth you're actually
    taking about.
    [color=blue]
    >The text remains. But it doesn't do anything. And I don't know
    >how to do that.[/color]

    <a href=""><img src="your button" alt=""></a>
    the text.

    What could be simpler?
    [color=blue][color=green][color=darkred]
    >>>It would just be slicker to be able
    >>>to do that, turn off the text link.[/color][/color]
    >[color=green]
    >>If you turn off the link then there is no link.[/color]
    >
    >Exactly.[/color]

    Do you want the link to exist or not? I'm very confused.
    [color=blue][color=green]
    >>If you want to hide the text[/color]
    >
    >I want the text to remain visible, to identify the button's link.[/color]

    Identify it how?
    [color=blue]
    >Maybe it just can't be done. Again, it would be nicer. But it's no
    >loss.[/color]

    I have no idea what you're actually trying to do. A URL normally
    helps.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

    Comment

    • Steve Pugh

      #17
      Re: DYNAMICALLY disable links with CSS?

      Mark Johnson <102334.12@comp userve.com> wrote:[color=blue]
      >Steve Pugh <steve@pugh.net > wrote:
      >[color=green]
      >>Hang on. You have <a href="">text</a> and you've styled it so that it
      >>has a changing background on :hover, right?[/color]
      >
      >No. It just stays as text. But a couple of nested divisions before it,
      >just float to the left, and can contain a button and hover-button,
      >separately, for a single anchor tag which duplicates the href link.[/color]

      So you actually have two links to the same resource?
      [color=blue]
      >Some of my styles don't do that Typically it's display:none.
      >But one does. It's a very different look than the others.[/color]

      Yes, different styles produce different looks. You have two links to
      the same resource styled differently and you don't want one of them to
      be a link? So remove the <a> element from the second one.
      [color=blue]
      >So I wanted to
      >transfer the click, the link, over to the button, and away from the
      >text.[/color]

      It's impossible (well except by changing the document with JavaScript)
      to 'transfer' a link or anything like that. You seem to be implying
      that you've managed to do this 'transferring' somehow. Telling us how
      would maybe give us some indication of what on earth you're actually
      taking about.
      [color=blue]
      >The text remains. But it doesn't do anything. And I don't know
      >how to do that.[/color]

      <a href=""><img src="your button" alt=""></a>
      the text.

      What could be simpler?
      [color=blue][color=green][color=darkred]
      >>>It would just be slicker to be able
      >>>to do that, turn off the text link.[/color][/color]
      >[color=green]
      >>If you turn off the link then there is no link.[/color]
      >
      >Exactly.[/color]

      Do you want the link to exist or not? I'm very confused.
      [color=blue][color=green]
      >>If you want to hide the text[/color]
      >
      >I want the text to remain visible, to identify the button's link.[/color]

      Identify it how?
      [color=blue]
      >Maybe it just can't be done. Again, it would be nicer. But it's no
      >loss.[/color]

      I have no idea what you're actually trying to do. A URL normally
      helps.

      Steve

      --
      "My theories appal you, my heresies outrage you,
      I never answer letters and you don't like my tie." - The Doctor

      Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

      Comment

      • Mark Johnson

        #18
        Re: DYNAMICALLY disable links with CSS?

        Steve Pugh <steve@pugh.net > wrote:
        [color=blue]
        >I have no idea what you're actually trying to do. A URL normally
        >helps.[/color]

        I just got the domain name, last week. I've got nothing on the site,
        as yet. I'm working to get the first version ready.

        But again, I have a text anchor, with URL, of course. And I have
        couple of DIVs, one of which duplicates the link, but both of which
        are typically not shown. They are placeholders, as with a number of
        other SPANs and DIVs on each page. Some styles use these. Others turn
        them off or ignore them. I have one style, among various, that uses
        buttons loaded as background images, as an alternative method for an
        image swap rollover, using only style sheets, and not javascript. But
        since in that style a button is used, is shown, I thought it redundant
        to also retain the anchor, the link, for the text, which is still
        shown. I wanted it simply to be treated as text, even though it is
        marked up with an anchor tag in the XHTML.

        Again, I could imagine a javascript work around, at the time the style
        is changed. These are selected from a dropdown box, and updated when
        the window is resized, in javascript. Part of that could also involve
        modifying certain links. But it would be too much of a kludge, I
        think. Then again, my use of containers for box corners/ears is a bit
        much if only IE would recognize corner-radius (on the other hand, it's
        more flexible if you don't simply want a pure radius every time).

        Anyway.

        Comment

        • Mark Johnson

          #19
          Re: DYNAMICALLY disable links with CSS?

          Steve Pugh <steve@pugh.net > wrote:
          [color=blue]
          >I have no idea what you're actually trying to do. A URL normally
          >helps.[/color]

          I just got the domain name, last week. I've got nothing on the site,
          as yet. I'm working to get the first version ready.

          But again, I have a text anchor, with URL, of course. And I have
          couple of DIVs, one of which duplicates the link, but both of which
          are typically not shown. They are placeholders, as with a number of
          other SPANs and DIVs on each page. Some styles use these. Others turn
          them off or ignore them. I have one style, among various, that uses
          buttons loaded as background images, as an alternative method for an
          image swap rollover, using only style sheets, and not javascript. But
          since in that style a button is used, is shown, I thought it redundant
          to also retain the anchor, the link, for the text, which is still
          shown. I wanted it simply to be treated as text, even though it is
          marked up with an anchor tag in the XHTML.

          Again, I could imagine a javascript work around, at the time the style
          is changed. These are selected from a dropdown box, and updated when
          the window is resized, in javascript. Part of that could also involve
          modifying certain links. But it would be too much of a kludge, I
          think. Then again, my use of containers for box corners/ears is a bit
          much if only IE would recognize corner-radius (on the other hand, it's
          more flexible if you don't simply want a pure radius every time).

          Anyway.

          Comment

          • Mark Johnson

            #20
            Re: DYNAMICALLY disable links with CSS?

            Mark Johnson <102334.12@comp userve.com> wrote:
            [color=blue]
            >But again, I have a text anchor, with URL, of course. And I have
            >couple of DIVs, one of which duplicates the link, but both of which
            >are typically not shown. They are placeholders, as with a number of
            >other SPANs and DIVs on each page. Some styles use these. Others turn
            >them off or ignore them. I have one style, among various, that uses
            >buttons loaded as background images, as an alternative method for an
            >image swap rollover, using only style sheets, and not javascript. But
            >since in that style a button is used, is shown, I thought it redundant
            >to also retain the anchor, the link, for the text, which is still
            >shown. I wanted it simply to be treated as text, even though it is
            >marked up with an anchor tag in the XHTML.[/color]

            You know, I wonder if rather than thinking of modifying event
            behavior, or rerouting it, that stylesheets could be used to hide a
            portion of an anchor, but not the rest? That is - hide the anchor, and
            so the behavior, but retain display of the text?

            Comment

            • Mark Johnson

              #21
              Re: DYNAMICALLY disable links with CSS?

              Mark Johnson <102334.12@comp userve.com> wrote:
              [color=blue]
              >But again, I have a text anchor, with URL, of course. And I have
              >couple of DIVs, one of which duplicates the link, but both of which
              >are typically not shown. They are placeholders, as with a number of
              >other SPANs and DIVs on each page. Some styles use these. Others turn
              >them off or ignore them. I have one style, among various, that uses
              >buttons loaded as background images, as an alternative method for an
              >image swap rollover, using only style sheets, and not javascript. But
              >since in that style a button is used, is shown, I thought it redundant
              >to also retain the anchor, the link, for the text, which is still
              >shown. I wanted it simply to be treated as text, even though it is
              >marked up with an anchor tag in the XHTML.[/color]

              You know, I wonder if rather than thinking of modifying event
              behavior, or rerouting it, that stylesheets could be used to hide a
              portion of an anchor, but not the rest? That is - hide the anchor, and
              so the behavior, but retain display of the text?

              Comment

              • Steve Pugh

                #22
                Re: DYNAMICALLY disable links with CSS?

                Mark Johnson <102334.12@comp userve.com> wrote:
                [color=blue]
                >Steve Pugh <steve@pugh.net > wrote:
                >[color=green]
                >>I have no idea what you're actually trying to do. A URL normally
                >>helps.[/color]
                >
                >I just got the domain name, last week. I've got nothing on the site,
                >as yet. I'm working to get the first version ready.[/color]

                If it was finished we wouldn't need to see it, would we? Stick it on
                free web space if you haven't purchased hosting yet.
                [color=blue]
                >But again, I have a text anchor, with URL, of course.[/color]

                <a href="foo">text </a>
                [color=blue]
                >And I have couple of DIVs,[/color]

                <div>...</div>
                <div>...</div>
                [color=blue]
                >one of which duplicates the link,[/color]

                Duplicated it how? By containing a _second_ <a href="foo"></a> ?
                [color=blue]
                >but both of which are typically not shown.[/color]

                display: none; or visibility: hidden; ?
                [color=blue]
                >They are placeholders, as with a number of other SPANs and DIVs on each page.
                >Some styles use these. Others turn them off or ignore them.[/color]

                You page has multiple style sheets?
                [color=blue]
                >I have one style, among various, that uses
                >buttons loaded as background images, as an alternative method for an
                >image swap rollover, using only style sheets, and not javascript.[/color]

                As IE does not support :hover except on <a> elements this very
                strongly implies that the "buttons" are duplicate <a href="foo"></a>
                elements.
                [color=blue]
                > But
                >since in that style a button is used, is shown, I thought it redundant
                >to also retain the anchor, the link, for the text, which is still
                >shown.[/color]

                In general it is poor usability to have multiple links to the same
                resource, but it's not an absolute rule. The important point is to
                make sure that the user knows that the links are the same - so make
                sure that both your text links and "buttons" have clear :visited
                styles so that users aren't fooled into following links that they've
                already visited.
                [color=blue]
                >I wanted it simply to be treated as text, even though it is
                >marked up with an anchor tag in the XHTML.[/color]

                I gave some styles in my first post that hide the appearance of being
                a link. Did you try them?

                There is no way in CSS to remove the link from an <a> element without
                removing the whole element.

                Steve

                --
                "My theories appal you, my heresies outrage you,
                I never answer letters and you don't like my tie." - The Doctor

                Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

                Comment

                • Steve Pugh

                  #23
                  Re: DYNAMICALLY disable links with CSS?

                  Mark Johnson <102334.12@comp userve.com> wrote:
                  [color=blue]
                  >You know, I wonder if rather than thinking of modifying event
                  >behavior, or rerouting it, that stylesheets could be used to hide a
                  >portion of an anchor, but not the rest? That is - hide the anchor, and
                  >so the behavior, but retain display of the text?[/color]

                  No. The link is a property of the whole <a> element not just part of
                  it. With JavaScript you can strip out the tags converting the <a>
                  element into a text node, or remove the href attribute node converting
                  it into a link-less <a> element. But with CSS all you can do is change
                  the presentation of the element.

                  Steve

                  --
                  "My theories appal you, my heresies outrage you,
                  I never answer letters and you don't like my tie." - The Doctor

                  Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

                  Comment

                  • Steve Pugh

                    #24
                    Re: DYNAMICALLY disable links with CSS?

                    Mark Johnson <102334.12@comp userve.com> wrote:
                    [color=blue]
                    >Steve Pugh <steve@pugh.net > wrote:
                    >[color=green]
                    >>I have no idea what you're actually trying to do. A URL normally
                    >>helps.[/color]
                    >
                    >I just got the domain name, last week. I've got nothing on the site,
                    >as yet. I'm working to get the first version ready.[/color]

                    If it was finished we wouldn't need to see it, would we? Stick it on
                    free web space if you haven't purchased hosting yet.
                    [color=blue]
                    >But again, I have a text anchor, with URL, of course.[/color]

                    <a href="foo">text </a>
                    [color=blue]
                    >And I have couple of DIVs,[/color]

                    <div>...</div>
                    <div>...</div>
                    [color=blue]
                    >one of which duplicates the link,[/color]

                    Duplicated it how? By containing a _second_ <a href="foo"></a> ?
                    [color=blue]
                    >but both of which are typically not shown.[/color]

                    display: none; or visibility: hidden; ?
                    [color=blue]
                    >They are placeholders, as with a number of other SPANs and DIVs on each page.
                    >Some styles use these. Others turn them off or ignore them.[/color]

                    You page has multiple style sheets?
                    [color=blue]
                    >I have one style, among various, that uses
                    >buttons loaded as background images, as an alternative method for an
                    >image swap rollover, using only style sheets, and not javascript.[/color]

                    As IE does not support :hover except on <a> elements this very
                    strongly implies that the "buttons" are duplicate <a href="foo"></a>
                    elements.
                    [color=blue]
                    > But
                    >since in that style a button is used, is shown, I thought it redundant
                    >to also retain the anchor, the link, for the text, which is still
                    >shown.[/color]

                    In general it is poor usability to have multiple links to the same
                    resource, but it's not an absolute rule. The important point is to
                    make sure that the user knows that the links are the same - so make
                    sure that both your text links and "buttons" have clear :visited
                    styles so that users aren't fooled into following links that they've
                    already visited.
                    [color=blue]
                    >I wanted it simply to be treated as text, even though it is
                    >marked up with an anchor tag in the XHTML.[/color]

                    I gave some styles in my first post that hide the appearance of being
                    a link. Did you try them?

                    There is no way in CSS to remove the link from an <a> element without
                    removing the whole element.

                    Steve

                    --
                    "My theories appal you, my heresies outrage you,
                    I never answer letters and you don't like my tie." - The Doctor

                    Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

                    Comment

                    • Steve Pugh

                      #25
                      Re: DYNAMICALLY disable links with CSS?

                      Mark Johnson <102334.12@comp userve.com> wrote:
                      [color=blue]
                      >You know, I wonder if rather than thinking of modifying event
                      >behavior, or rerouting it, that stylesheets could be used to hide a
                      >portion of an anchor, but not the rest? That is - hide the anchor, and
                      >so the behavior, but retain display of the text?[/color]

                      No. The link is a property of the whole <a> element not just part of
                      it. With JavaScript you can strip out the tags converting the <a>
                      element into a text node, or remove the href attribute node converting
                      it into a link-less <a> element. But with CSS all you can do is change
                      the presentation of the element.

                      Steve

                      --
                      "My theories appal you, my heresies outrage you,
                      I never answer letters and you don't like my tie." - The Doctor

                      Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

                      Comment

                      • Ulujain

                        #26
                        Re: DYNAMICALLY disable links with CSS?

                        Jakob wrote:
                        [color=blue]
                        >
                        > I could think of a reason.
                        > Suppose you want a secret link, a link you don't want strangers to use,
                        > but for friends or relatives it's OK.[/color]

                        Set up authentication for it and give your friends and relatives the URL
                        and the password.

                        'Later
                        Peter

                        --
                        Peter aka Ulujain - Computing for Fun!

                        Comment

                        • Ulujain

                          #27
                          Re: DYNAMICALLY disable links with CSS?

                          Jakob wrote:
                          [color=blue]
                          >
                          > I could think of a reason.
                          > Suppose you want a secret link, a link you don't want strangers to use,
                          > but for friends or relatives it's OK.[/color]

                          Set up authentication for it and give your friends and relatives the URL
                          and the password.

                          'Later
                          Peter

                          --
                          Peter aka Ulujain - Computing for Fun!

                          Comment

                          • Karl Smith

                            #28
                            Re: DYNAMICALLY disable links with CSS?

                            Steve Pugh <steve@pugh.net > wrote:
                            [color=blue]
                            > Mark Johnson <102334.12@comp userve.com> wrote:
                            >[color=green]
                            > >I wanted it simply to be treated as text, even though it is
                            > >marked up with an anchor tag in the XHTML.[/color]
                            >
                            > There is no way in CSS to remove the link from an <a> element without
                            > removing the whole element.[/color]

                            To disable a link using only CSS, no JavaScript, position a
                            transparent element over the link text and give it a higher z-index so
                            it is "in front of" the link text.

                            This newsgroup often has messages from people who have accidentally
                            disabled links while experimenting with absolute positioning.

                            --
                            Karl Smith.

                            Comment

                            • Karl Smith

                              #29
                              Re: DYNAMICALLY disable links with CSS?

                              Steve Pugh <steve@pugh.net > wrote:
                              [color=blue]
                              > Mark Johnson <102334.12@comp userve.com> wrote:
                              >[color=green]
                              > >I wanted it simply to be treated as text, even though it is
                              > >marked up with an anchor tag in the XHTML.[/color]
                              >
                              > There is no way in CSS to remove the link from an <a> element without
                              > removing the whole element.[/color]

                              To disable a link using only CSS, no JavaScript, position a
                              transparent element over the link text and give it a higher z-index so
                              it is "in front of" the link text.

                              This newsgroup often has messages from people who have accidentally
                              disabled links while experimenting with absolute positioning.

                              --
                              Karl Smith.

                              Comment

                              • Steve Pugh

                                #30
                                Re: DYNAMICALLY disable links with CSS?

                                google-2003-03@kjsmith.com (Karl Smith) wrote:
                                [color=blue]
                                >Steve Pugh <steve@pugh.net > wrote:
                                >[color=green]
                                >> Mark Johnson <102334.12@comp userve.com> wrote:
                                >>[color=darkred]
                                >> >I wanted it simply to be treated as text, even though it is
                                >> >marked up with an anchor tag in the XHTML.[/color]
                                >>
                                >> There is no way in CSS to remove the link from an <a> element without
                                >> removing the whole element.[/color]
                                >
                                >To disable a link using only CSS, no JavaScript, position a
                                >transparent element over the link text and give it a higher z-index so
                                >it is "in front of" the link text.[/color]

                                Does that also disable the link if the user is navigating with the
                                keyboard rather than the mouse?

                                Steve

                                --
                                "My theories appal you, my heresies outrage you,
                                I never answer letters and you don't like my tie." - The Doctor

                                Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

                                Comment

                                Working...