加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

dojo学习笔记(六)- ContentPane

发布时间:2020-12-16 21:54:02 所属栏目:百科 来源:网络整理
导读:实现功能:在一个容器里点击一个链接,在另外一个容器中显示这个链接所指向页面的内容。 html head script src="./dojo/dojo.js" /script script dojo.require("dojo.widget.ContentPane"); var links = null,display = null; dojo.addOnLoad(init); functio

实现功能:在一个容器里点击一个链接,在另外一个容器中显示这个链接所指向页面的内容。
<html>
<head>
<script src="./dojo/dojo.js">
</script>
<script>
dojo.require("dojo.widget.ContentPane");
var links = null,display = null;
dojo.addOnLoad(init);
function init(){
links = dojo.widget.byId("links");
display = dojo.widget.byId("display");

// listen to links domNode for onclick event
// lowercased on all DOM events as opposed to widget events

//"onclick",必须是小写的
dojo.event.connect(links.domNode,"onclick",'relayClicks');

} // finds out if this is a link event function relayClicks(evt){ var node = evt.target;//取得事件源 if(node.nodeName.toLowerCase() == "a"){ // it is a link,prevent the browser from unloading the page evt.preventDefault(); // change page in display pane display.setUrl(node.href); } } </script></head><body> <h1>Example on how to easily relay <a href="someurl.html" target="display"> clicks</h1> <div dojoType="ContentPane" widgetId="links" style="float:left ; width: 200px; height: 400px; border: 1px solid red;" > <a href="link1.html">Link 1</a><br/> <a href="link2.html">Link 2</a><br/> <a href="link3.html">Link 3</a><br/> </div> <div dojoType="ContentPane" widgetId="display" name="display" id ="display" style="width: 600px; height: 400px; border: 1px solid blue;" ></div></body></html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读