I have a little script that enables a link on a button if a checkbox is ticked. Basically the user has to agree that the link is an external one by ticking a box, then the link becomes active.
When people browse away from the page then press the back button the checkbox remains ticked but the links are inactive, the user has to untick the box then retick the box. Is it possible to make the link active when using the back button?
Here is what I am doing
When people browse away from the page then press the back button the checkbox remains ticked but the links are inactive, the user has to untick the box then retick the box. Is it possible to make the link active when using the back button?
Here is what I am doing
Code:
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
var [ignore]link[/ignore]1 = $("#to-toggle");
var [ignore]link[/ignore]2 = $("#to-toggle2");
$("#toggle").on("change", function() {
if(this.checked) {
[ignore]link[/ignore]1.attr("href", [ignore]link[/ignore]1.data("href"));
[ignore]link[/ignore]2.attr("href", [ignore]link[/ignore]2.data("href"));
} else {
[ignore]link[/ignore]1.removeAttr("href");
[ignore]link[/ignore]2.removeAttr("href");
}
});
});//]]>
</script>
<input id="toggle" type="checkbox">
<a id="to-toggle" data-href="link"><img src="image.png" /></a>
<a id="to-toggle2" data-href="[ignore]link[/ignore]2"><img src="image2.png" /></a>