Help - Search - Members - Calendar
Full Version: Button Anchor link not activating
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
masonh928
Hi guys, it has been forever since I've last posted! Hope you are all well! biggrin.gif

I wonder if you remember me; but that's not my purpose of this post... lol

Anyways, so I have this anchor link <a> inside a <button> for bootstrap stylization purposes; however, for some reason the link is not activating, even though I know that the link works. Copy and pasted into the browser!

Click the blue button under the pages header. (Return to >> Rare Breeds))

Here is the button/link code: (In PHP, I needed to get the URL Parameters, but not relevant) The HTML rendered -
CODE

<button class='btn-primary'><a href='/Pages.php?Go=Poultry&&Type=RareBreed&&Yes=true'> Return to &gg; Rare Breed</a></button>


Anything stick out?

Thanks guys!
CharlesEF
Maybe because you have 2 '&&' symbols in the query string when only 1 is needed?
pandy
Of course we remember you. biggrin.gif

The link doesn't work in gecko browsers either. The only browser it works in for me is Iron (Chrome clone).

I don't think the double ampersands are a mistake because they are used in all links and the other ones work. I guess one of them is in the actual query. I don't know if that's allowed or advisable though.

The double ampersands are in this link and in all the links to rare breeds on that page and they all work.
CODE
http://indiancreekpoultry.000webhostapp.com/Pages.php?Go=Poultry&&Type=RareBreed

http://indiancreekpoultry.000webhostapp.co...;Type=RareBreed
pandy
I take that back. The links work with single ampersands too. How can it be that both versions work? wacko.gif

Still, the back link works only in iron, single or double ampersands. The ampersands should be URL encoded, but I don't see why that should break anything in one single link. unsure.gif
pandy
Ah, BUTTON can't contain links. Simple as that.

http://htmlhelp.com/reference/html40/forms/button.html

CODE
Contents
Inline elements except A, INPUT, SELECT, TEXTAREA, LABEL, BUTTON, and IFRAME
Block-level elements except FORM, ISINDEX, and FIELDSET


Still wonder about those ampersands though... ninja.gif
pandy
WTF? It works with any number of ampersands.

CODE
http://indiancreekpoultry.000webhostapp.com/Pages.php?Go=Poultry&&&&&&&&Type=RareBreed&&&&&&&&&&&&&&&&&&&&&&&Yes=true

http://indiancreekpoultry.000webhostapp.co...p;&Yes=true

Here too, but here the excessive ampersands are cleaned up (look at the address bar).
CODE
http://forums.htmlhelp.com/index.php?s=&showtopic=59289&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&view=findpost&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&p=134352

http://forums.htmlhelp.com/index.php?s=&am...p;&p=134352
Christian J
QUOTE(pandy @ Apr 10 2017, 12:37 PM) *

Ah, BUTTON can't contain links. Simple as that.

Same thing in HTML5, which says "there must be no interactive content descendant":
https://www.w3.org/TR/2014/REC-html5-201410...-button-element
https://www.w3.org/TR/2014/REC-html5-201410...ctive-content-0
pandy
Yeah, should have spotted that right off. But what's with the ampersands?
Christian J
AFAIK double ampersands shouldn't exist (ampersand in existing URLs should be URL-encoded as %26 when used in a query string), so maybe it's a bug.
pandy
In all browsers? And this forum software is designed to work with them.
Christian J
Seems this forum makes 302 redirects in the background where the extra ampersands are stripped out.

When I used my own test server the extra ampersands remained in the URL, so my browsers are not correcting anything. PHP's
$_SERVER['QUERY_STRING'] doesn't remove them either, but print_r($_GET) manages to sort it out, e.g. this query string ?x=y&&&foo=bar
returns this:

CODE
Array
(
    [x] => y
    [foo] => bar
)

...and not something like [x] => &&y. So if I'd let PHP create a new query string out of the above array the extra ampersands wouldn't get included in it.
pandy
No, browsers don't remove any ampersands, but the right page is still loaded. That's my point. Why does it work at all? I would have though that all but one ampersand would be seen as part of the query that ought to fail miserably.

Where is Darin? I bet he knows this stuff.
Christian J
QUOTE(pandy @ Apr 11 2017, 12:35 AM) *

I would have though that all but one ampersand would be seen as part of the query that ought to fail miserably.

Maybe the extra ampersands are simply regarded as empty name/value pairs. If so a server-side script might ignore them (maybe depending on language). For example, with this query string:

CODE
?x=y&&&foo=bar

PHP's $_GET['x'] and $_GET['foo'] return the perfectly normal values "y" and "bar". If you instead make an array of the query string with

CODE
explode('&', $_SERVER['QUERY_STRING']);

you get this:

CODE
Array
(
    [0] => x=y
    [1] =>
    [2] =>
    [3] => foo=bar
)

with the extra "&" characters resulting in empty array items, but those should never used for anything in a PHP script anyway (unless the script looped through the unsanitized array regardless of the items it contains, but that might be bad coding practice).
Darin McGrew
QUOTE
Maybe the extra ampersands are simply regarded as empty name/value pairs.
That's my guess. Technically, empty name/value pairs would look like this:

&=&=&=&=&

because there's supposed to be an equals sign between the name and the value, but I bet the libraries used for parsing the input to server-side programs clean all that up and ignore the empty bits.
pandy
Hm. Strange. Perl seems to do it too. Hard to find this kind of Perl scripts these days but I found this gallery that is happy to accept my multi ampersands.

CODE
http://www.emalbum.com/cgi-bin/emAlbum.cgi?cmd=show_image&&&&&&path=Animals&&&&&&img=1&&&&&&tn=1


http://www.emalbum.com/cgi-bin/emAlbum.cgi...;&&tn=1
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.