PDA

View Full Version : help me fix this java script please



vijetha
08-17-2010, 05:53 AM
hi i want to implement this java script .This is the Original Java script page .
(http://www.pmanslab.com/projects/tabBrowser/frames/tabPageFrame.php#)

Where you see if i click on the yahoo or | google buttons the new window is loading and the same page is displaying with a tab bar menu and close button. I want to implement the same on one of my documents where i created css and java script based drop down menus. But when i tried to implement the same java script on my own page its not working properly.Please help me fix it .
I have changed the code only on Button -4 Link-1 only

Hers the Live Demo of the page :
Live Demo Of The Page (http://vijethansp.com/chaitu/index.htm)

Heres the Java Script:

Java Script (http://vijethansp.com/chaitu/js/tabbed_browser.js)

Here's the CSS :


html,body {
padding:0;
margin: 0px;
background: #306f80;
}
#wrapper{
width: 1024px;
margin-right: auto;
margin-left: auto;
background: #FFFFFF;
height: 1000px;
}
#header{
height: 100px;
width: 1024px;
background: url(../images/header.png) repeat-x;
}
.icons_hold{
float: right;
height: 55px;
width: 200px;
position: relative;
top: 10px;
right: 10px;
}
.navestyle{
width: 1024px;
font-weight: bold;
margin-right: auto;
margin-left: auto;
}
.navestyle:after{ /*Add margin between menu and rest of content in Firefox*/
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.navestyle ul{
border: 1px solid #BBB;
width: 100%;
background: url(../images/nav_bg.png) repeat-x center center; /*THEME CHANGE HERE*/
padding: 4px 0;
margin: 0;
text-align: center;
font: 12px Verdana, Arial, Helvetica, sans-serif;
}
.navestyle ul li{
display: inline;
margin-right: 2px;
margin-left: 2px;
}
.navestyle ul li a{
color: #494949;
padding: 4px 45px 4px 7px;
margin: 0;
text-decoration: none;
border-right: 1px solid #DADADA;
}
.navestyle ul li a:hover, .navestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/
background: url(../images/hover.png) repeat-x center center; /*THEME CHANGE HERE*/
color: #FFFFFF;
}

/* ######### Style for Drop Down Menu ######### */

.dropmenudiv{
position:absolute;
top: 0;
border: 1px solid #BBB; /*THEME CHANGE HERE*/
border-bottom-width: 0;
font:normal 12px/18px Verdana, Arial, Helvetica, sans-serif;
z-index:100;
background-color: white;
visibility: hidden;
width: 200px;
}


.dropmenudiv a{
width: auto;
display: block;
text-indent: 3px;
border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/
padding: 2px 0;
text-decoration: none;
font-weight: bold;
color: black;
}

* html .dropmenudiv a{ /*IE only hack*/
width: 100%;
}

.dropmenudiv a:hover{ /*THEME CHANGE HERE*/
background-color: #F0F0F0;
}
img
{
border: none;
}
.pagination{
padding: 0px 2px 2px;
clear: both;
}

.pagination ul{
margin: 0;
padding: 0;
text-align: center; /*Set to "right" to right align pagination interface*/
font-size: 16px;
}

.pagination li{
list-style-type: none;
display: inline;
padding-bottom: 1px;
}

.pagination a, .pagination a:visited{
padding: 0 5px;
border: 1px solid #9aafe5;
text-decoration: none;
color: #2e6ab1;
}

.pagination a:hover, .pagination a:active{
border: 1px solid #2b66a5;
color: #000;
background-color: #FFCC33;
}

.pagination a.currentpage{
background-color: #2e6ab1;
color: #FFF !important;
border-color: #2b66a5;
font-weight: bold;
cursor: default;
}

.pagination a.disablelink, .pagination a.disablelink:hover{
background-color: white;
cursor: default;
color: #929292;
border-color: #929292;
font-weight: normal !important;
}

.pagination a.prevnext{
font-weight: bold;
}
#demoArea
{
padding: 10px ;
height: 580px ;
background: #FFFFFF ;
/*border: 1px solid black ;*/
/*display: table ;*/
}

#demoLinks
{
width: 20% ;
border-right: 1px dotted blue ;
float: left ;
}

#demoBrowser
{
position: relative;
width: 950px;
margin-left: auto;
margin-right: auto;
}

#tabBrowser
{
position: absolute ;
width: 100% ;
}

/* --------------- TABS -------------------*/

#tabDemo
{
display: none
}

#tabContainer
{
display: block ;
}

#tabs
{
cursor: default ;
list-style-type: none ;
/*width: 560px ;*/
margin: 0 ;
padding: 0 ;
}

#tabs li
{
background: #FFFBF0 ;
border: 1px solid green ;
border-bottom: 0 ;
-moz-border-radius-topleft: 5px ;
-moz-border-radius-topright: 5px ;
float: left ;
width: 100px ;
min-width: 35px ;
height: 20px ;
margin: 0 2px 3px 0 ;
padding-left: 3px ;
}

.tabTitle
{
float: left ;
width: 80% ;
height: 100% ;
overflow: hidden ;
}

.closeTab
{
text-align: center ;
text-transform: uppercase ;
margin: 2px 3px 2px 80% ;
border: outset 1px #D40000 ;
}

.closeTab:hover
{
background: #000000;
}

/* --------------- BROWSER -------------------*/

#tabContent
{
position: relative ;
clear: both ;
width: 100% ;
}

#tabContent div
{
position: absolute ;
width: 100% ;
}


Here's the Mark Up :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Testing page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/tabbed_browser.js"></script>
<script type="text/javascript" src="js/chrome.js">


</script>
</head>

<body>
<div id="wrapper">
<div id="header">
<div class="icons_hold"><a href="#"><img src="images/home.png" title="home" /></a>&nbsp;&nbsp;&nbsp;<a href="#"><img src="images/help.png" title="help" /></a>&nbsp;&nbsp;&nbsp;<a href="#"><img src="images/sign_out.png" title="signe out" /></a></div>

</div>


<div class="navestyle" id="navemenu">
<ul>
<li><a href="#" title="chaitnyas testing page">Button-1</a></li>
<li><a href="#" title="chaitnyas testing page">Button-2</a></li>
<li><a href="#" title="chaitnyas testing page">Button-3</a></li>

<li><a href="#" rel="dropmenu1" title="chaitnyas testing page">Button-4</a></li>
<li><a href="#" rel="dropmenu2" title="chaitnyas testing page">Button-5</a></li>
<li><a href="#" rel="dropmenu3" title="chaitnyas testing page">Button-6</a></li>
<li><a href="#" title="chaitnyas testing page">Button-7</a></li>
<li><a href="#" title="chaitnyas testing page">Button-8</a></li>
</ul>
</div>

<!--1st drop down menu -->
<div id="dropmenu1" class="dropmenudiv">
<a id="link1" onclick="openTab('link1')" href="http://yahoo.com." title="chaitnyas testing page" ><img src = "images/1.gif" />&nbsp;Link-1</a>
<a href="link-2.htm" title="chaitnyas testing page"><img src = "images/2.gif" />&nbsp;Link-2</a>
<a href="link-3.htm" title="chaitnyas testing page"><img src = "images/3.gif" />&nbsp;Link-3</a>
<a href="link-4.htm" title="chaitnyas testing page"><img src = "images/4.gif" />&nbsp;Link-4</a>
<a href="link-5.htm" title="chaitnyas testing page"><img src = "images/5.gif" />&nbsp;Link-5</a></div>


<!--2nd drop down menu -->
<div id="dropmenu2" class="dropmenudiv" style="width: 150px;">
<a href="#" title="chaitnyas testing page"><img src = "images/6.gif" />&nbsp;Link-1</a>
<a href="#" title="chaitnyas testing page"><img src = "images/7.gif" />&nbsp;Link-2</a>
<a href="#" title="chaitnyas testing page"><img src = "images/8.gif" />&nbsp;Link-3</a></div>

<!--3rd drop down menu -->
<div id="dropmenu3" class="dropmenudiv" style="width: 150px;">
<a href="#" title="chaitnyas testing page"><img src = "images/9.gif" />&nbsp;Link-1</a>
<a href="#" title="chaitnyas testing page"><img src = "images/10.gif" />&nbsp;Link-2</a>
<a href="#" title="chaitnyas testing page"><img src = "images/11.gif" />&nbsp;Link-3</a></div>


<script type="text/javascript">

cssdropdown.startchrome("navemenu")

</script>
<p><br />
<div id="demoBrowser">
<div id="tabBrowser">
<div id="tabContainer">
<ul id="tabs"><li id="tabDemo"><div class="tabTitle">Google</div><div class="closeTab">x</div></li>
</ul>
</div>
<div id="tabContent">
</div>
</div>
</div>
</div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />

</p>
<div class="pagination">
<ul>

<li><a href="products.htm" class="currentpage" title="Products">1</a></li>
<li><a href="products1.htm" title="Products">2</a></li>
<li><a href="products2.htm" title="Products">3</a></li>


</ul>
</div><br />


</p>
</div>
</body>

</html>

jscheuer1
08-17-2010, 03:34 PM
This markup:



<a id="link1" onclick="openTab('link1')" href="http://yahoo.com." title="chaitnyas testing page" ><img src = "images/1.gif" />&nbsp;Link-1</a>

is wrong. And I don't think there is a http://yahoo.com., it's http://www.yahoo.com/ - But that may not be important. If you look at Pman's demo page, you will see that the link is inside another element, in Pman's case, an li, which has the event on it. You can use a span, that would probably work out better for what you're doing. And I think even Pman might approve of adding a return false value, so we would have (for your link):


<span id="link1" onclick="openTab('link1'); return false;"><a href="http://www.yahoo.com/" title="chaitnyas testing page" ><img src = "images/1.gif" />&nbsp;Link-1</a></span>