The function below works in FireFox and Internet Explorer but it does not work in Safari. In Safari, when you click nothing happens.
How can I fix the function to work also in Safari?
I've checked that JavaScript is enabled (tested in 3 different machines already).
Thanks a ton
<script>
function win() {
$("#main").remove();
$("#content_target").html('<div style="z-index:2;background:url(img/frame_main.png) no-repeat;text-align:left;width:726px;height:491px;"><div id="target" style="padding:5% 5%;float:left"></div> </div>');
$("#target").load("myphp.php", {variable1: "myvariable", variable2: 12}, functio开发者_运维技巧n(){
$("#my_div").css('background', 'url("img/img_ACTI.png") no-repeat');
});
}
</script>
<div onclick="javascript:win();" ><a href="#">Click me</a></div>
Give this a try, putting the function into a click trigger...
<script>
function win() {
$("#main").remove();
$("#content_target").html('<div style="z-index:2;background:url(img/frame_main.png) no-repeat;text-align:left;width:726px;height:491px;"><div id="target" style="padding:5% 5%;float:left"></div> </div>');
$("#target").load("myphp.php", {variable1: "myvariable", variable2: 12}, function(){
$("#my_div").css('background', 'url("img/img_ACTI.png") no-repeat');
});
}
$("#clickMe").click(function(){
win();
});
</script>
<div id="clickMe" ><a href="#">Click me</a></div>
This should work:
<script>
$("#clickme").click(function(event) {
$("#main").remove();
$("#content_target").html('<div style="z-index:2;background:url(img/frame_main.png) no-repeat;text-align:left;width:726px;height:491px;"><div id="target" style="padding:5% 5%;float:left"></div></div>');
$("#target").load("myphp.php", {variable1: "myvariable", variable2: 12}, function(){
$("#my_div").css('background', 'url("img/img_ACTI.png") no-repeat');
});
event.preventDefault();
});
</script>
<div><a href="#" id="clickme">Click me</a></div>
精彩评论