Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2003, 05:49 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default Navigator/Gecko Headaches!

I'm having a bit of trouble getting my JavaScript to run in Navigator 7 / Mozilla 1.*. The following is the code library I am using between <head></head> tags (probably irrelevant). It all works fine and dandy in Internet Explorer 6, but in NS/Mozilla anything that refers to something in this block of script doesn't work. When I reference a function in this code block and open up JS Console in Navigator, it complains that the function in undefined.

I have similar script contained in a separate block that is used for dynamic menus that works in Navigator, but behaves unpredictably, the onmouseout event handler doesn't *always* behave as it should, it only works part of the time.

I'm going nutty trying to get this thing sorted, is there something obvious in this code that is causing the Gecko browsers to choke? (This is output from PHP, so take heed of any strange syntax... that is included variables/constants from the PHP side of things).

There is also an occaisonal error that pops up in JS console, saying something about a missing parenthesis near the function declaration for goto.. yet I can not see where one is missing (even more boggling is the whole thing works in IE 6). Here is the error text:

Error: missing ( before formal parameters
Source File: http://smilingsouls.net/
Line: 84, Column: 13
Source Code:
function goto(the_location)

So far I've come up with naught from Google...

I'd sincerely appreciate a fresh pair of eyes!

: )
Rich

Code:
<script language='JavaScript' type='text/javascript'>

    function draw_window(info_path, window_name, x, y)
    {
        var open_path;
        var open_attributes;

        open_path        = '{$_SERVER["PHP_SELF"]}?jsinclude_path=' + info_path;
        open_attributes = 'width=' + x + ', height=' + y + ', scrollbars = yes, resizable = yes';

        window.open(open_path, window_name, open_attributes);
        return;
    }

    function bg_onfocus(this_field, error_boolean)
    {
        if (error_boolean == true)
        {
            document.getElementById(this_field).style.color = '".COLOR_INPUT_TEXT."';                    
        }

        document.getElementById(this_field).style.background = '".COLOR_ONFOCUS."';

        return;
    }

    function bg_onblur(this_field, error_boolean)
    {        
        if (error_boolean == true)
        {
            document.getElementById(this_field).style.color = '".COLOR_INPUT_TEXT."';
        }

        document.getElementById(this_field).style.background = '".COLOR_INPUT."';

        return;
    }

    function bgin(id)
    {
        document.getElementById(id).style.background    = '".COLOR_BODY."';
        document.getElementById(id).style.borderWidth   = 1 + 'px';

        return;
    }

    function bgout(id)
    {
        document.getElementById(id).style.background    = 'transparent';
        document.getElementById(id).style.borderWidth   = 0 + 'px';

        return;
    }

    function menu_in(id)
    {
        document.getElementById(id).style.display  = 'block';
        return;
    }

    function menu_out(id)
    {
        document.getElementById(id).style.display  = 'none';
        return;
    }

    function goto(the_location)
    {
        location.href = the_location;
        return;
    }

    var scrolling;

    function startScroll(theframe)
    {
        scrolling=setInterval('window.' + theframe + '.scrollBy(0,12);', 100);
    }

    function stopScroll()
    {
        clearInterval(scrolling);
    }

    function back(theframe)
    {
        scrolling=setInterval('window.' + theframe + '.scrollBy(0,-12);', 100);
    }

</script>\n";
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old December 23rd, 2003, 08:22 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I was able to figure out the source of my ills:

goto, is a reserved word.. thus not allowing my to use it as a function name, at least in the Gecko Browsers. Which I wasn't able to stumble across until I ran the JavaScript console in Mozilla 1.6 instead of NS 7. I changed that and solved my problem.

My JavaScript however executes rather sporadically. As I mentioned before, the onmouseout event handler that I use doesn't always fire (in NS) and is rather annoying.

Here is a complete functioning script... could this be done a better way?

Thanks!
: )
Rich

Code:
<html>
    <head>
        <style>

            a 
            {
                color: black;
            }

            div.menulink
            {
                border: 0px solid black;
                width: 200px;
                padding: 3px 0px 3px 0px;
                position: relative;
                z-index: 998;
            }

            div.menuborder
            {
                border-bottom: 1px solid black;
                padding: 2px 0px 2px 0px;
                margin-bottom: 2px;
            }                        

            div.submenu
            {
                position: absolute;
                top: -1px;
                right: -180px;
                width: 175px;
                display: none;
                border: 1px solid black;
                padding: 3px;
                z-index: 1000;
                background: blue;
            }

            div.submenuarrow
            {
                position: absolute;
                top: 3px;
                right: 6px;
                z-index: 998;
            }

        </style>
        <script language='JavaScript' type='text/javascript'>

            function bgin(id)
            {
                document.getElementById(id).style.background    = '#0099cc';
                document.getElementById(id).style.borderWidth   = 1 + 'px';

                return;
            }

            function bgout(id)
            {
                document.getElementById(id).style.background    = 'transparent';
                document.getElementById(id).style.borderWidth   = 0 + 'px';

                return;
            }

            function menu_in(id)
            {
                document.getElementById(id).style.display  = 'block';
                return;
            }

            function menu_out(id)
            {
                document.getElementById(id).style.display  = 'none';
                return;
            }

            function go_to(the_location)
            {
                location.href = the_location;
                return;
            }

    </script>
    </head>
    <body>    

        <div id='ss3' class='menulink' onmouseover='bgin("ss3"), menu_in("int")' onmouseout='bgout("ss3"), menu_out("int")' title="Get specialized, professional help!">
            <span style="margin-left: 8px;"><a href='/index.html?site=intuition&amp;sid=95356e7a05b89e72c2ef95496cc82379&amp;PHPSESSID=95356e7a05b89e72c2ef95496cc82379'>intuitive souls</a></span>

            <div class='submenuarrow'>
                <img src='images/color_schemes/white_background/menu_unselected.png' style='width: 10px; height: 10px;' id='folderselected' class='noborder' />
            </div>



            <div class='submenu' id='int' onmouseover='menu_in("int"), bgin("ss3")' onmouseover='menu_out("int")'>
                <div class='menuborder'>
                    <div id='int0' class='menulink' style='margin-top: 0px; margin-bottom: 0px;' onclick='goto("/index.html?site=intuition&amp;sid=95356e7a05b89e72c2ef95496cc82379")' onmouseover='bgin("int0")' onmouseout='bgout("int0")' title='About intuitive souls.'>

                        <span style='margin-left: 5px;'><a href='/index.html?site=intuition&amp;sid=95356e7a05b89e72c2ef95496cc82379&amp;PHPSESSID=95356e7a05b89e72c2ef95496cc82379'>home</a></span>

                    </div>
                </div>
                    <div id='int1' class='menulink' style='margin-top: 0px; margin-bottom: 0px;' onclick='goto("/index.html?content=351&amp;sid=95356e7a05b89e72c2ef95496cc82379")' onmouseover='bgin("int1")' onmouseout='bgout("int1")' title='title text'>
                        <span style='margin-left: 5px;'><a href='/index.html?content=351&amp;sid=95356e7a05b89e72c2ef95496cc82379&amp;PHPSESSID=95356e7a05b89e72c2ef95496cc82379'>link 1</a></span>
                    </div>
                    <div id='int2' class='menulink' style='margin-top: 0px; margin-bottom: 0px;' onclick='goto("/index.html?content=228&amp;sid=95356e7a05b89e72c2ef95496cc82379")' onmouseover='bgin("int2")' onmouseout='bgout("int2")' title='title text'>
                        <span style='margin-left: 8px;'><a href='/index.html?content=228&amp;sid=95356e7a05b89e72c2ef95496cc82379&amp;PHPSESSID=95356e7a05b89e72c2ef95496cc82379'>link 2</a></span>
                    </div>
                    <div id='int3' class='menulink' style='margin-top: 0px; margin-bottom: 0px;' onclick='goto("/index.html?content=234&amp;sid=95356e7a05b89e72c2ef95496cc82379")' onmouseover='bgin("int3")' onmouseout='bgout("int3")' title='title text'>
                        <span style='margin-left: 8px;'><a href='/index.html?content=234&amp;sid=95356e7a05b89e72c2ef95496cc82379&amp;PHPSESSID=95356e7a05b89e72c2ef95496cc82379'>link 3</a></span>
                    </div>
            </div>
        </div>
    </body>
</html>


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding Navigator sirmilt BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 March 13th, 2006 07:34 AM
gecko based xpath paultman BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 2 October 15th, 2005 01:36 PM
About dynamic navigator bar... SeanTsang BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 14th, 2005 07:09 AM
Overflow scrollbars vs. div size in IE vs. Gecko mishagos BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 4 April 3rd, 2005 02:38 PM
Oracle headaches: editing a user's permissions pankaj_daga Oracle 4 May 11th, 2004 06:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.