Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 12-31-2007, 07:07 PM Invalid Javascript
TripleMoons's Avatar
Webmaster Talker

Posts: 614
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
I found script for drop down content that I very much like but I'm getting Invalid Errors. Could someone please take a look at it and explain how to make it valid?

What it does can be viewed here:
http://triplemoonsdesign.com/services.html

Javascript
Code:
<script type="text/javascript">            
    var slideDownInitHeight = new Array();
    var slidedown_direction = new Array();

    var slidedownActive = false;
    var contentHeight = false;
    var slidedownSpeed = 3;     // Higher value = faster script
    var slidedownTimer = 7;    // Lower value = faster script
    function slidedown_showHide(boxId)
    {
        if(!slidedown_direction[boxId])slidedown_direction[boxId] = 1;
        if(!slideDownInitHeight[boxId])slideDownInitHeight[boxId] = 0;
        
        if(slideDownInitHeight[boxId]==0)slidedown_direction[boxId]=slidedownSpeed; else slidedown_direction[boxId] = slidedownSpeed*-1;
        
        slidedownContentBox = document.getElementById(boxId);
        var subDivs = slidedownContentBox.getElementsByTagName('DIV');
        for(var no=0;no<subDivs.length;no++){
            if(subDivs[no].className=='dhtmlgoodies_content')slidedownContent = subDivs[no];    
        }

        contentHeight = slidedownContent.offsetHeight;
    
        slidedownContentBox.style.visibility='visible';
        slidedownActive = true;
        slidedown_showHide_start(slidedownContentBox,slidedownContent);
    }
    function slidedown_showHide_start(slidedownContentBox,slidedownContent)
    {

        if(!slidedownActive)return;
        slideDownInitHeight[slidedownContentBox.id] = slideDownInitHeight[slidedownContentBox.id]/1 + slidedown_direction[slidedownContentBox.id];
        if(slideDownInitHeight[slidedownContentBox.id] <= 0){
            slidedownActive = false;    
            slidedownContentBox.style.visibility='hidden';
            slideDownInitHeight[slidedownContentBox.id] = 0;
        }
        if(slideDownInitHeight[slidedownContentBox.id]>contentHeight){
            slidedownActive = false;    
        }
        slidedownContentBox.style.height = slideDownInitHeight[slidedownContentBox.id] + 'px';
        slidedownContent.style.top = slideDownInitHeight[slidedownContentBox.id] - contentHeight + 'px';

        setTimeout('slidedown_showHide_start(document.getElementById("' + slidedownContentBox.id + '"),document.getElementById("' + slidedownContent.id + '"))',slidedownTimer);    // Choose a lower value than 10 to make the script move faster
    }
    
    function setSlideDownSpeed(newSpeed)
    {
        slidedownSpeed = newSpeed;
        
    }
    </script>
HTML
Code:
<div id="dhtmlgoodies_control">&bull; <a href="#" onclick="slidedown_showHide('box1');return false;">Content Management</a></div>
    <div class="dhtmlgoodies_contentBox" id="box1">
        <div class="dhtmlgoodies_content" id="subBox1">
            <!-- slide down content goes here -->
            Content management is a database driven system that allows users to update information on a web site via an administrative panel. No knowledge of HTML or CSS is required to make changes to pages connected to a CMS. For more information, please <a href="http://www.triplemoonsdesign.com/blog" target="_blank">see our blog</a>.
            <!-- End slide down content -->
        </div>
    </div>
</div>
CSS
Code:
.dhtmlgoodies_contentBox{
        border:2px solid #ED1878;
        height:0px;
        visibility:hidden;
        position:absolute;
        background-color:#666666;
        overflow:hidden;
        padding: 0px 5px 5px 5px;
        width:300px;
                
}
.dhtmlgoodies_content{
        position:relative;        
        font-family: "Century Gothic", Futura, Arial;
        width:100%;
        font-size:12px;
        text-align: justify;
        
}

Last edited by TripleMoons; 12-31-2007 at 07:09 PM..
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
 
Register now for full access!
Old 01-01-2008, 12:10 AM Re: Invalid Javascript
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Since the site you link to doesn't throw any errors in FF, I'll assume you've got this fixed and just forgot to tell us. If not, then please give more details on the error.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-01-2008, 03:37 AM Re: Invalid Javascript
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Script seems to be working OK.

Constructive criticism - could do with a refresher on HTML and CSS.

Are you really quoting from Wikipedia.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 01-01-2008, 06:16 PM Re: Invalid Javascript
TripleMoons's Avatar
Webmaster Talker

Posts: 614
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
Since the site you link to doesn't throw any errors in FF, I'll assume you've got this fixed and just forgot to tell us. If not, then please give more details on the error.
The invalid errors can be seen here. Their are seven. Not too sure why you aren't seeing the errors.
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
Old 01-01-2008, 09:06 PM Re: Invalid Javascript
Experienced Talker

Posts: 39
Name: Andrew
Trades: 0
(Just jumping in - hope OK...)

The validator is interpreting your JS as HTML and, not surprisingly, it's not very happy about that. I'm not sure if that's the way it should work (anyone know?), and certainly no browser made in the past 10 or so years would make that mistake, but sticking comment tags around the script (as with the first one) - or better putting the scripts in an external file - will probably solve the issue.
__________________

Please login or register to view this content. Registration is FREE
- Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
Old 01-01-2008, 09:29 PM Re: Invalid Javascript
TripleMoons's Avatar
Webmaster Talker

Posts: 614
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
I like the idea of putting it into an external file. Less code in the HTML.

How do I go about doing that and making it work? I put the Javascript into its own file called dropdowncontent.js and linked it to the HTML file this way:

Code:
<script type="text/javascript" src="dropdowncontent.js">
</script>
However it doesn't seem to be working. I don't think it's reading the CSS file?
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
Old 01-01-2008, 10:06 PM Re: Invalid Javascript
Experienced Talker

Posts: 39
Name: Andrew
Trades: 0
It works fine for me, locally at least. Is it reading the JS file? (e.g. if you stick an alert("hi"); at the beginning of the file, does it stick up a box?)
__________________

Please login or register to view this content. Registration is FREE
- Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
Old 01-01-2008, 11:36 PM Re: Invalid Javascript
TripleMoons's Avatar
Webmaster Talker

Posts: 614
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
You can see here that it's not working.

These are the Firebug errors:

syntax error
UIUpdate()UIUpdate.js (line 30)

[IMG]chrome://firebug/content/blank.gif[/IMG] if(!slidedown_direction[boxId])slidedown_direction[boxId] = 1;\

slidedown_showHide is not defined
onclick(click clientX=0, clientY=0)

Last edited by TripleMoons; 01-01-2008 at 11:42 PM..
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
Old 01-01-2008, 11:45 PM Re: Invalid Javascript
Experienced Talker

Posts: 39
Name: Andrew
Trades: 0
You don't need this <script type="text/javascript"> in an external script file.
__________________

Please login or register to view this content. Registration is FREE
- Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
Old 01-02-2008, 12:20 AM Re: Invalid Javascript
TripleMoons's Avatar
Webmaster Talker

Posts: 614
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
Code:
<script src="dropdowncontent.js">
</script>
Created three Firebug errors and doesn't work.
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
Old 01-02-2008, 04:48 AM Re: Invalid Javascript
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
What meloncholy is saying is you should NOT have the "<script type= ...>" delimiter tags actually IN the external file.

the "type" attribute HAS to be on the declaration of the external file though.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-02-2008, 12:06 PM Re: Invalid Javascript
TripleMoons's Avatar
Webmaster Talker

Posts: 614
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
Oooooooooo. I didn't even realize I'd stuck it in the .js file!
Thanks! That worked perfectly!
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
Reply     « Reply to Invalid Javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55607 seconds with 12 queries