i have a php code in a div. I'd like to cancel clicking on that div, until the page loads.

i'm having the problem if i click on the div too fast which calls a popup div... it doesn't get the content from the php.. so it is a blank popup div.

Recommended Answers

All 3 Replies

You could wait to attach the click event listener on that div until the dom is finished loading. If you use jQuery you would set up in a javascript block

<script>
$(document).ready(function(){
  $(#yourDiv).click(function(){ 
    /* fire popup */
  });
});
</script>

i tried below but now the onclick is not working. I want the function ShowContent only be able to run when the document(php) has loaded.

$(document).ready(function(){
  $("block").click(
					
					function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);

AssignPosition(dd);

dd.style.display = "block";

}
					
					
					);
});

So the div you are attaching the click event to has the id = "block"? To attach the event to block you need to use

$("#block").click(function(){});

Also where is the parameter 'd' coming from? If you don't declare d be fore the click event it will be null. Try having d as a value on the div that as you are clicking and use

$("#block").click(function(){
 var d = this.getAttribute("d");
 var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = ""; /* don't need to declare it block */
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.