hashsplit
hashsplit is JS plugin to use various values from URL fragment identifier (hash) #foo , #foo/bar or #foo=bar&city=springfield
It uses the values from the hash with DOM-Id in a specific way:
- forms (inputs, selects) are filled (works only with pseudogets
&name=value
or/name=value
)- checkbox get checked on 'true' or any string, but unchecked with 'false' or '' (empty string) only.
- links (
a
) get a click (e.g. you want to link on a page with an active fancybox)
usage
<script src="https://cdn.jsdelivr.net/gh/klml/hashsplit@master/hashsplit.js" type="text/javascript"></script>
<script>
hashsplit(); // activate hashspilt
updateHash(); // get changed input values back to hash
</script>
inspiration
Initial JS from Cristian Sanchez on stackoverflow.com. accounts.google.com is using the function 'InputHolder.prototype.prefill' doing similar the same as this function 'HashSplit'.
Any ideas for:
- img
similar usage
- formassembly
- jQuery BBQ
- contactform7 for wordpress Getting Default Values from the Context
- stackoverflow questions on this:
version
- 1.0
- 3.0 removed tabs, use CSS :target
todo:
- this
- hooks
- alert