Reputation: 15683
I am playing with a very simple jquery modal windows. It opens the modal windows by clicking on
<a href="#" id="clickMe">Click Me</a>
How can I make this javascript action by adding an attribute to the URL, e.g. index.php?q=clickMe or index.html#clickMe
I mean when visiting the webpage of index.html (with q=clickMe or #clickMe), loading the page with opened modal. In other words, the attribute plays the role of CLICK on id="clickMe" for jQuery.
Upvotes: 0
Views: 116
Reputation: 15931
first i would get a jquery plug in for reading querysting variables - like getUrlParam
then, you can do it in script
$(document).ready(function() {
if ($(document).getUrlParam("activate-click").length > 0) {
$("#clickMe").click();
}
});
Upvotes: 1
Reputation: 86892
You would need to handle the QueryString or URL Hash in the document.ready().
Here is an example of handling the hash #clickMe
$(document).ready(function () {
if (window.location.hash == "#clickMe") {
//open modal
}
});
Upvotes: 1