【发布时间】:2012-10-23 21:37:07
【问题描述】:
几天前,我在堆栈上找到了一些解决我的问题的方法。代码如下:
HTML:
<a class="link" data-toggle="modal" href="link1.php" >Link 1</a>
<a class="link" data-toggle="modal" href="link2.php" >Link 2</a>
<a class="link" data-toggle="modal" href="link3.php" >Link 3</a>
<div class="modal hide fade" id="myModal"></div>
jQuery:
$("a.link").click(function(){
$("#myModal").html($(this).attr("href"));
/*$("#myModal").load($(this).attr("href"));*/
return false;
});
但是,这只适用于 Opera。在所有其他浏览器中,链接永远不会在mymodal div 中打开。
完整代码在这里
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#prvidiv {
width:360px;
height: 220px;
border: 1px;
padding: 5px;
font-family: cool_font, sans-serif;
font-size:24px;
color:#0000CC;
background-color:transparent;
}
#levideookvir{
float:left;
width: 760px;
height:800px;
margin-right:0px;
margin-top: 0px;
}
</style>
<script src="jqery/jquery.min.js"></script>
</head>
<body>
<script language="javascript">
$(document).ready(function() {
$("a.link").click(function(e){
$("#levideookvir").html($(this).attr("href"));
$("#levideookvir").load($(this).attr("href"));
window.alert('Request complete');
e.preventDefault();
})
});
</script>
<div id="prvidiv">
Ovde ide link<br />
<a class="link" href="test2.html">Klikni me</a><br />
</div>
<div id="levideookvir" >OVDE REY</div>
</body>
</html>
因为它很奇怪...我什至没有收到我在 Chrome、Safari 或 FF 中运行此脚本时定义的 ALERT。 正如我所说...只在歌剧中工作。
【问题讨论】:
标签: jquery load opera href attr