Войти

Показать полную графическую версию : Смена контента при нажатии на ссылки


LennyTao
25-09-2011, 17:42
Добрый день, родные!
В общем, такая проблема. Есть скрипт, функция которого заключается в том, что при нажатии на разные ссылки меняется исходный текст. Этот скрипт мне нужно объединить с древовидным меню, но у меня не получается!... Древовидное меню работает по такому принципу, что один скрипт прописывается в коде к странице, а другой заливается в корневую папку. В коде страницы прописывают пункты меню и ссылки к ним, а в корневой папке идёт привязка ссылок к пунктам. Скину все скрипты ниже. Может кто-нибудь сможет объединить или хотя бы направить. Лично сам пробовал разные способы. Кто будет кидать варианты, откомментирую...

Скрипт замены контента:

<script language="javascript">
var texter=Array();
texter[1]='<iframe src="http://nimpo-world.com/dir/2-1-0-1" style="border: medium none ;" width="490" height="100%" hspace="0" vspace="0" allowtransparency="true" scrolling="no" frameborder="0"></iframe>';
texter[2]='<iframe src="http://nimpo-world.com/dir/2-1-0-2" style="border: medium none ;" width="490" height="239" hspace="0" vspace="0" allowtransparency="true" scrolling="no" frameborder="0"></iframe>';
function spisok(id){
return texter[id];
}
</script>

<a href="javascript: void(0);" onClick="document.getElementById('spisok').innerHTML = spisok(1);return false;">1</a>
<a href="javascript: void(0);" onClick="document.getElementById('spisok').innerHTML = spisok(2);return false;">2</a>
<a href="javascript: void(0);" onClick="document.getElementById('spisok').innerHTML = spisok(3);return false;">3</a>


Скрипт меню в странице:

<!--

d = new dTree('d');

d.add(0,-1,'Меню');
d.add(1,0,'Пункт 1','Ссылка 1');
d.add(2,1,'Пункт 2','Ссылка 2');
d.add(3,2,'Пункт 3','Ссылка 3')

document.write(d);

//-->


Скрипт привязывания ссылки к пункту:

// Creates the node icon, url and text

dTree.prototype.node = function(node, nodeId) {

var str = '<div class="dTreeNode">' + this.indent(node, nodeId);

if (this.config.useIcons) {

if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);

if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;

if (this.root.id == node.pid) {

node.icon = this.icon.root;

node.iconOpen = this.icon.root;

}

str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';

}

if (node.url) {

str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';

if (node.title) str += ' title="' + node.title + '"';

if (node.target) str += ' target="' + node.target + '"';

if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';

if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))

str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';

str += '>';

}

else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)

str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';

str += node.name;

if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';

str += '</div>';

if (node._hc) {

str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';

str += this.addNode(node);

str += '</div>';

}

this.aIndent.pop();

return str;

};




© OSzone.net 2001-2012