2013-02-14 109 views
0

根據演示http://raphaeljs.com/australia.html,我想添加onclick事件到演示。我的想法是,無論何時用戶點擊某個狀態,它都會指向某個網站。例如,如果用戶點擊新南威爾士州,我希望用戶被引導到一個網站http://en.wikipedia.org/wiki/New_South_Wales添加onclick事件來調用rapahael中的某個超鏈接

任何人都可以分享一些解決方案嗎?

在此先感謝。 沙拉德

+0

你可以添加這部分代碼:st [0] .onclick = function(){//在onmouseout事件之後你想要做的任何事情}。 – 2013-02-14 08:38:55

+0

嗨,你能否詳細說明一下?我有七個不同的網站地址和七個州。我不能知道如何告訴rapahel選擇正確的網址。 – user1857493 2013-02-14 13:09:13

+0

請參閱下面的答案。 – 2013-02-14 13:39:09

回答

0

可能的解決方案:

先放各州所有鏈接和斯托特項(同DIV ID)爲assoc命令數組:

var links = { 'nsw':'http://en.wikipedia.org/wiki/New_South_Wales','sa':'http://en.wikipedia.org/wiki/South_Australia'}; //i am too lazy to find all links, just fill till the end in same style 

然後調用onmouseevent後此方法(在索引頁) :

st[0].onclick = function(){ 
    window.open(links[current]); //current contain same value as div id (for example wa for Western Australia. this would open new window. 
}