php - HTML disable enter in my code -
i have code
<a href=" ?page=<?php echo $_get['page'] ?> &tab=<?php echo $_get['tab'] ?> &subtab=list" nazwa</a> chrome renders above code this:
?page=nurk-edycja-tresci-home &tab=artykuly &subtab=list with lot of whitespaces :c know cause comming coding style me improves readability lot. there solution reconcile style browsers? ;)
keeping white-space server-side
it doesn't html syntax valid, you're missing > when php preprocessed, won't return of whitecaps in code should good:
<a href="<?php echo '?page' . $_get['page']; echo '&tab' . $_get['tab']; echo '&subtab=list"; ?>">nazwa</a> you put whitespace in <?php ?> server process , return client
<a href="<?php ?>?page=<?=$_get['page'] ?><?php ?>&tab=<?=$_get['tab'] ?><?php ?>&subtab=list" >nazwa</a> you can replace <?php echo <?=
how it
<a href="<?= '?page=', $_get['page'], '&tab', $_get['tab'], '&subtab=list' ?>"> this syntax readable , let's put newlines:
<a href="<?= '?page=', $_get['page'], '&tab', $_get['tab'], '&subtab=list' ?>"> javascript?
if really code right now, can use javascript rid of spaces:
(function () { window.onload = function () { var elems = document.getelementsbytagname('a'), = 0; (; < elems.length; += 1) { elems[i].href = (elems[i].href || '').replace(/\s/g, ''); } } }()); even shorter:
window.onload = function () { array.prototype.foreach.call(document.getelementsbytagname('a'), function (t) { t.href = (t.href || '').replace(/\s/g, '') }) } ecmascript2015 (harmony):
window.onload = () => array.from(document.queryselectorall('a[href]')).map(t => (t.href = a.href.replace(/\s/g, ''));
Comments
Post a Comment