我的网页上有一个链接
<li data="url: 'www.mypage.com?index.php?CId=2&MId=14&MTId=1'">mylink
在我的js脚本中 我有
$(document).ready(function() {
$("#tree").dynatree({
persist: true,
onPostInit: function(isReloading, isError) {
this.reactivate();
},
onActivate: function(dtnode) {
var isInitializing = dtnode.tree.isInitializing();
var isReloading = dtnode.tree.isReloading();
var isUserEvent = dtnode.tree.isUserEvent();
if( dtnode.data.url )
window.open(dtnode.data.url);
}
});
});
我应该做什么而不是window.open
,以便网址在同一窗口中重新加载,而不是打开一个新窗口?
网页中没有名称可以使用 iFrame 方式。
最佳答案
我建议
onActivate: function(node) {
if( node.data.href ){
// use href to change the current frame:
window.location.href = node.data.href;
// or load data into a div tag:
// $("#div").load(node.data.href);
// or open href in another target frame:
// window.open(node.data.href, node.data.target);
}
}
另请参阅此处的另一个示例:How to make hyperlinks in dynaTree jQuery plugin clickable?
关于JQuery DynaTree 插件 - 如何调用超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3386581/