javascript - Append Query String From Variable To Every URL -
i created query string , appended url so:
// html index.html <input type="button" value="yes" onclick="redirect(this);" id="yes" class="btn btn-primary btn-lg"> <input type="button" value="no" onclick="redirect(this);" id="no" class="btn btn-primary btn-lg"> // js on index.html function redirect(e){ var mappg = "map.html"; var qstring = "?choice="; location.href = mappg + qstring + e.id; } beginning on map.html page, want take query string , carry through every url, except index.html page.
when user clicks on price.html pg, it'll use query string call function pull in data "yes" answer. same thing goes "no" answer.
i can't figure out how append query string url of every pg on click.
the nav javascript include that's been pulled in. i've added class of qstring the<a> in nav in case easier target them.
is jquery option? if so...
<script type="text/javascript"> $(document).ready(function() { $("a").prop("href", function() { return this.href + location.search; }) }); </script>
Comments
Post a Comment