PDA

View Full Version : كد جاوا براي منوي سايت



mahtab_m
سه شنبه 23 تیر 1388, 09:00 صبح
سلام من يه سايت استاتيك دارم با چند گزينه بالاي صفحه مثل زير

ورزشي|اجتماعي|خانواده

ميخوام روي هر كدوم كه كليك كنم زيرش اطلاعات يا صفحه مربوط به اون نشون داده بشه
چه طور با جاوا اسكريپت ميتونم اين كارو بكنم؟

saeid99
سه شنبه 23 تیر 1388, 10:20 صبح
بهتره از نرم افزار زیر استفاده کنی..
Sothink DHTML Menu

mosi-online
سه شنبه 23 تیر 1388, 15:31 عصر
جاوا رو ول کن.

#menuh-container
{
position: absolute;
top: 1em;
left: 1em;
}

#menuh
{
font-size: small;
font-family: arial, helvetica, sans-serif;
width:100%;
float:left;
margin:2em;
margin-top: 1em;
}

#menuh a
{
text-align: center;
display:block;
border: 1px solid #555;
white-space:nowrap;
margin:0;
padding: 0.3em;
}

#menuh a:link, #menuh a:visited, #menuh a:active /* menu at rest */
{
color: white;
background-color: royalblue;
text-decoration:none;
}

#menuh a:hover /* menu on mouse-over */
{
color: white;
background-color: cornflowerblue;
text-decoration:none;
}

#menuh a.top_parent, #menuh a.top_parent:hover /* attaches down-arrow to all top-parents */
{
background-image: url(navdown_white.gif);
background-position: right center;
background-repeat: no-repeat;
}

#menuh a.parent, #menuh a.parent:hover /* attaches side-arrow to all parents */
{
background-image: url(nav_white.gif);
background-position: right center;
background-repeat: no-repeat;
}

#menuh ul
{
list-style:none;
margin:0;
padding:0;
float:left;
width:9em; /* width of all menu boxes */
/* NOTE: For adjustable menu boxes you can comment out the above width rule.
However, you will have to add padding in the "#menh a" rule so that the menu boxes
will have space on either side of the text -- try it */
}

#menuh li
{
position:relative;
min-height: 1px; /* Sophie Dennis contribution for IE7 */
vertical-align: bottom; /* Sophie Dennis contribution for IE7 */
}

#menuh ul ul
{
position:absolute;
z-index:500;
top:auto;
display:none;
padding: 1em;
margin:-1em 0 0 -1em;
}

#menuh ul ul ul
{
top:0;
left:100%;
}

div#menuh li:hover
{
cursor:pointer;
z-index:100;
}

div#menuh li:hover ul ul,
div#menuh li li:hover ul ul,
div#menuh li li li:hover ul ul,
div#menuh li li li li:hover ul ul
{display:none;}

div#menuh li:hover ul,
div#menuh li li:hover ul,
div#menuh li li li:hover ul,
div#menuh li li li li:hover ul
{display:block;}

/* End CSS Drop Down Menu *


<attach event="ondocumentready" handler="parseStylesheets" />
<script>
/**
* Whatever:hover - V1.41.050927 - hover & active
* ------------------------------------------------------------
* (c) 2005 - Peter Nederlof
* Peterned - http://www.xs4all.nl/~peterned/
* License - http://creativecommons.org/licenses/LGPL/2.1/
*
* Whatever:hover is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Whatever:hover is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Credits and thanks to:
* Arnoud Berendsen, Martin Reurings, Robert Hanson
*
* howto: body { behavior:url("csshover.htc"); }
* ------------------------------------------------------------
*/

var csshoverReg = /(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i,
currentSheet, doc = window.document, hoverEvents = [], activators = {
onhover:{on:'onmouseover', off:'onmouseout'},
onactive:{on:'onmousedown', off:'onmouseup'}
}

function parseStylesheets() {
if(!/MSIE (5|6)/.test(navigator.userAgent)) return;
window.attachEvent('onunload', unhookHoverEvents);
var sheets = doc.styleSheets, l = sheets.length;
for(var i=0; i<l; i++)
parseStylesheet(sheets[i]);
}
function parseStylesheet(sheet) {
if(sheet.imports) {
try {
var imports = sheet.imports, l = imports.length;
for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);
} catch(securityException){}
}

try {
var rules = (currentSheet = sheet).rules, l = rules.length;
for(var j=0; j<l; j++) parseCSSRule(rules[j]);
} catch(securityException){}
}

function parseCSSRule(rule) {
var select = rule.selectorText, style = rule.style.cssText;
if(!csshoverReg.test(select) || !style) return;

var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
var className = (/\.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
var affected = select.replace(/:(hover|active).*$/, '');
var elements = getElementsBySelect(affected);
if(elements.length == 0) return;

currentSheet.addRule(newSelect, style);
for(var i=0; i<elements.length; i++)
new HoverElement(elements[i], className, activators[pseudo]);
}

function HoverElement(node, className, events) {
if(!node.hovers) node.hovers = {};
if(node.hovers[className]) return;
node.hovers[className] = true;
hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });
hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('\\s+'+className, 'g'),''); });
}
function hookHoverEvent(node, type, handler) {
node.attachEvent(type, handler);
hoverEvents[hoverEvents.length] = {
node:node, type:type, handler:handler
};
}

function unhookHoverEvents() {
for(var e,i=0; i<hoverEvents.length; i++) {
e = hoverEvents[i];
e.node.detachEvent(e.type, e.handler);
}
}

function getElementsBySelect(rule) {
var parts, nodes = [doc];
parts = rule.split(' ');
for(var i=0; i<parts.length; i++) {
nodes = getSelectedNodes(parts[i], nodes);
} return nodes;
}
function getSelectedNodes(select, elements) {
var result, node, nodes = [];
var identify = (/\#([a-z0-9_-]+)/i).exec(select);
if(identify) return [doc.getElementById(identify[1])];

var classname = (/\.([a-z0-9_-]+)/i).exec(select);
var tagName = select.replace(/(\.|\#|\:)[a-z0-9_-]+/i, '');
var classReg = classname? new RegExp('\\b' + classname[1] + '\\b'):false;
for(var i=0; i<elements.length; i++) {
result = tagName? elements[i].all.tags(tagName):elements[i].all;
for(var j=0; j<result.length; j++) {
node = result[j];
if(classReg && !classReg.test(node.className)) continue;
nodes[nodes.length] = node;
}
} return nodes;
}
</script>

<!--[if lt IE 7]>
<style type="text/css" media="screen">
#menuh{float:none;}
body{behavior:url(csshover.htc); font-size:100%;}
#menuh ul li{float:left; width: 100%;}
#menuh a{height:1%;font:bold 0.7em/1.4em arial, sans-serif;}
</style>
<![endif]-->
</head>


<div id="menuh-container">
<div id="menuh">
<ul>
<li><a href="#" class="top_parent">Item 1</a>
<ul>
<li><a href="#">Sub 1:1</a></li>
<li><a href="#" class="parent">Sub 1:2</a>
<ul>
<li><a href="#">Sub 1:2:1</a></li>
<li><a href="#">Sub 1:2:2</a></li>
<li><a href="#">Sub 1:2:3</a></li>
<li><a href="#">Sub 1:2:4</a></li>
</ul>
</li>
<li><a href="#">Sub 1:3</a></li>
<li><a href="#" class="parent">Sub 1:4</a>
<ul>
<li><a href="#">Sub 1:4:1</a></li>
<li><a href="#">Sub 1:4:2</a></li>
<li><a href="#">Sub 1:4:3</a></li>
<li><a href="#">Sub 1:4:4</a></li>
</ul>
</li>
<li><a href="#" class="parent">Sub 1:5</a>
<ul>
<li><a href="#">Sub 1:5:1</a></li>
<li><a href="#">Sub 1:5:2</a></li>
<li><a href="#">Sub 1:5:3</a></li>
<li><a href="#">Sub 1:5:</a></li>
<li><a href="#">Sub 1:5:5</a></li>
</ul>
</li>
</ul>
</li>
</ul>

<ul>
<li><a href="#" >Item 2</a>
</ul>

... repeat and alter the list as needed

</div> <!-- end the menuh-container div -->
</div> <!-- end the menuh div -->

araz1367
سه شنبه 23 تیر 1388, 23:27 عصر
این هم کد با استفاده از جاوا به نحوی میشه گفت که منوی پویا هم هست وقتی ماوس رو روی تصویر مورد نظر ببری به طور خودکار منو تغییر اندازه داده و با کلیک روی آن اطلاعات نیز در پایین ظاهر میشود:

<html>
<head>
<title> </title>
<script type="text/javascript">
var i=200;
var j=80;
function larg(vid)
{
document.getElementById(vid).style.height=j
document.getElementById(vid).style.width=j
}
function small(vid)
{
document.getElementById(vid).style.height=j
document.getElementById(vid).style.width=i
}
function writeText(txt)
{
document.getElementById("desc").innerHTML=txt;
}
</script>
</head>
<body background="images/b3.jpg">
<div dir="rtl">
<center>
<TABLE CELLSPACING="0" CELLPADDING="5" BORDER="0" >
<TR>
<TD COLSPAN="5" ALIGN="center"rowspan="1">
<img src="images/my banner.jpg" />
</TD>
</TR>
<TR>
<TD WIDTH="50%" ALIGN="middle">
<div id='d1' style="position: static;left: 100;z-index: 0">
<img id="m1" src="images/l-1.jpg" onmouseover="larg('m1')" alt="???? ????" onmouseout="small('m1')" height="60" width="180" usemap="#d1" />

</TD>
</div>
<TD WIDTH="50%" ALIGN="middle">
<div style="position: static;left: 120;z-index: 1">

<img id="m2" src="images/l2.jpg" onmouseover="larg('m2')" alt="?????? ??" onmouseout="small('m2')" height="60" width="180" usemap="#d2" />

</TD>
</div>
<TD WIDTH="50%" ALIGN="middle">
<div style="position: static;left: 150;z-index: 2">

<img id="m3" src="images/l5.jpg" onmouseover="larg('m3')" alt="??????? ???? ?????" onmouseout="small('m3')" height="60" width="180" usemap="#d3" />

</TD>
</div>
<TD WIDTH="50%" ALIGN="middle">
<div style="position: static;left: 200;z-index: 3">

<img id="m4" src="images/l4.jpg" onmouseover="larg('m4')" alt="?????? ??" onmouseout="small('m4')" height="60" width="180" usemap="#d4" />

</TD>
</div>
<TD WIDTH="50%" ALIGN="middle">
<div style="position: static;left: 250;z-index: 3">
<img id="m5" src="images/l6.jpg" onmouseover="larg('m5')" alt="?????? ??" onmouseout="small('m5')" height="60" width="180" usemap="#d5" />
</TD>
</div>
</TR>

</TABLE>
<map id ="d1" name="d1">
<area shape="default" coords="0,0,82,120"
onclick="writeText('safhe asli syte')"
/>
</map>
<p id="desc"></p>

<map id ="d2" name="d2">
<area shape="default" coords="0,0,82,120"
onclick="writeText('man ramin goolizadeh </br> daneshjoye reshteh computer')"
/>
</map>
<p id="desc"></p>

<map id ="d3" name="d3">
<area shape="default" coords="0,0,82,120"
onclick="writeText('www.tarfandaraz.blogfa.com </br> www.barnamenevis.org</br> <br> ')"
/>
</map>
<p id="desc"></p>

<map id ="d4" name="d4">
<area shape="default" coords="0,0,82,120"
onclick="writeText('nadaram')"
/>
</map>
<p id="desc"></p>

<map id ="d5" name="d4">
<area shape="default" coords="0,0,82,120"
onclick=writeText <a href="mailto:arazwebmaster@yahoo.com"> </a>
/>
</map>
<p id="desc"></p>
</div>

</body>
</html>:قلب:

mahtab_m
شنبه 27 تیر 1388, 08:46 صبح
بهتره از نرم افزار زیر استفاده کنی..
Sothink DHTML Menu

ممنون .من اين نرم افزار رو دانلود كردم . ولي با اين نرم افزار فقط ميتونم منو درست كنم. كه البته منوي من خيلي ساده هست و نيازي به اين نرم افزار نداشت .من مي خوام وقتي روي لينك كليك كنم به صفحه ديگه اي نرم و تو همين صفحه پايين منو نشون داده بشه اين كارو چه طوري بايد انجام بدم؟

saeid99
پنج شنبه 19 شهریور 1388, 16:19 عصر
ممنون .من اين نرم افزار رو دانلود كردم . ولي با اين نرم افزار فقط ميتونم منو درست كنم. كه البته منوي من خيلي ساده هست و نيازي به اين نرم افزار نداشت .من مي خوام وقتي روي لينك كليك كنم به صفحه ديگه اي نرم و تو همين صفحه پايين منو نشون داده بشه اين كارو چه طوري بايد انجام بدم؟

شما میتونی ار فریم استفاده کنید و target لینک های منو رو برابر نام فریم بزارید..