I have code that I am using to create a modal window. The way I was taught the code used a button to open the modal window. How would I modify the code to have it open when clicking a link? Here is the code:
Neither button had an onclick event initially in your code so I assumed the javascript sets this. If not then you would simply add 'openModal()' to the onclick event in the code above. Everything else should function as usual.
"Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"
All you are doing is making your button element look like a link, rather than actually using an anchor element. Alternative, you can use an anchor element with an onclick event handler defined as attribute.
Last edited by mavigozler; 11-16-2012 at 11:42 AM.
Neither button had an onclick event initially in your code so I assumed the javascript sets this. If not then you would simply add 'openModal()' to the onclick event in the code above. Everything else should function as usual.
Thanks for your response but I am having one other issue. I have a dropdown list that has the links that are going to open the modal windows. As I have it coded, the modal Mask is only masking the menu area and not the entire page. Also, when I hover off of the menu to the location of the modal window it disappears (closes) without me clicking on anything.
I am trying to use SimpleModal to create the modal windows on my site. Please everyone forget the previous posts as I have scrapped that code. I have not learned Javascript or Jquery yet so this is so confusing to me. I am a php guy and cant seem to figure out what is going on with this code. It says that it is a simple plugin that creates a modal window. First off, where do I put this code:
HTML Code:
$("myElement").addEvent("click", function(){
var SM = new SimpleModal({"width":600});
SM.addButton("Action button", "btn primary", function(){
this.hide();
});
SM.addButton("Cancel", "btn");
SM.show({
"model":"modal-ajax",
"title":"Title",
"param":{
"url":"file-content.php",
"onRequestComplete": function(){ /* Action on request complete */ }
}
});
});
When I try to do this it says that the url /javascript does not exist on this server. So what am I doing wrong? Does the javascript go in the head of the page its being called or right before the link that is being clicked? I am getting frusterated as I have coded my entire forum with php, html, and css and I would like to implement some modal windows for certain functions such as registration, forgoten passwords and such. If someone could please help me out that would save me so much time. If anyone is familiar with http://simplemodal.plasm.it/ that is where I got the code that I am using.
Bookmarks