javascript only runs one script???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmect
    New Member
    • Mar 2007
    • 6

    #1

    javascript only runs one script???

    I have a website (www.taxxman.co m/contacts.html) that contains javascript to round corners and adds a google map on the same page. The problem I'm having is that only the script for google maps works. On the other page, the rounding code works fine. I'm a newbie at javascript, so any help / advice you can give me will be much appreciated. Thanks!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by mmect
    I have a website (www.taxxman.co m/contacts.html) that contains javascript to round corners and adds a google map on the same page. The problem I'm having is that only the script for google maps works. On the other page, the rounding code works fine. I'm a newbie at javascript, so any help / advice you can give me will be much appreciated. Thanks!
    You will need to provide more details.
    So you say you have two pages. On each of these pages only one script is working? What's the difference between these pages? Do your pages have all the values expected by both scripts?

    Comment

    • chaarmann
      Recognized Expert Contributor
      • Nov 2007
      • 785

      #3
      Originally posted by mmect
      I have a website (www.taxxman.com/contacts.html) that contains javascript to round corners and adds a google map on the same page. The problem I'm having is that only the script for google maps works. On the other page, the rounding code works fine. I'm a newbie at javascript, so any help / advice you can give me will be much appreciated. Thanks!
      You are lucky that both that you want already works. You only need it to work together. This you can achieve easily with "morphing".
      Morphing is the process in which you first append the source code of the second page at the end of the first page. Then you take away some unwanted source code parts that came form the second page, one by one, in a way that the code still works. I mean, if you delete some code and one of both desired functions stop working, then undo the changes an try with some other source code parts. At the end you have developed a page where both works.

      I want to emphasize that this is a mechanical work, you don't need to understand the source code for it. But of course a little understanding helps much in doing it faster.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        please post the source-code ... simply doing trial&error may get the thing to work ... but i guess that is not the solution for you. lets have a look at it together and you will get explainations why the code is not working and how you may fix it. understanding what you are doing is much better then those simple cut&paste-methods ...

        kind regards

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          If you check the error console, you will see that map.addcontrol is not a function. It should be map.addControl (JavaScript is case-sensitive). This probably prevents the round corner script from working.

          Comment

          • mmect
            New Member
            • Mar 2007
            • 6

            #6
            Here's the script in the header...please let me know if you can help. I'm sure there's some consolidating of the code that I could do...just not sure where to start. Please not that I took out the Google Map Key.

            Code:
            <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<GOOGLE MAP KEY HERE>" type="text/javascript"></script>
            
            <script type="text/javascript">
                //<![CDATA[
                function load() {
                  if (GBrowserIsCompatible()) {
            			var map = new GMap(document.getElementById("map"));
            			map.centerAndZoom(new GPoint(-93.025092, 44.984877), 7);
            	
            			// Miller Tax Service
            			var point = new GPoint(-93.025092, 44.984877);
            			var marker = new GMarker(point);
            			map.addOverlay(marker);
            
            			//These are map controls.  You can add more by going to Google Maps - API
            			map.addControl(new GLargeMapControl());
            			map.addcontrol(new GMapTypeControl());
                  }
                }
                //]]>
            </script>
            
            <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
            </script>
            
            <script type="text/javascript">
            _uacct = "UA-2917358-1";
            urchinTracker();
            </script>
            
            <script type="text/javascript" src="rounded_corners.js"></script>
            
            <script type="text/javascript">
            
              window.onload = function()
              {
                  /*
                  The new 'validTags' setting is optional and allows
                  you to specify other HTML elements that curvyCorners
                  can attempt to round.
            
                  The value is comma separated list of html elements
                  in lowercase.
            
                  validTags: ["div", "form"]
            
                  The above example would enable curvyCorners on FORM elements.
                  */
                  settings = {
                      tl: { radius: 15 },
                      tr: { radius: 15 },
                      bl: { radius: 15 },
                      br: { radius: 15 },
                      antiAlias: true,
                      autoPad: true,
                      validTags: ["div"]
                  }
            
                  /*
                  Usage:
            
                  newCornersObj = new curvyCorners(settingsObj, classNameStr);
                  newCornersObj = new curvyCorners(settingsObj, divObj1[, divObj2[, divObj3[, . . . [, divObjN]]]]);
                  */
                  var myBoxObject = new curvyCorners(settings, "myBox");
                  myBoxObject.applyCornersToAll();
              } 
            </script>
            If you go to taxxman.com/contacts, you'll see non-rounded corners...the rest of the site's pages has rounded corners, however...I think the code above is where the problem is.

            Thank you all for your responses! I appreciate it.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              The first problem is line 17 in your code. Compare it to line 16. The "c" in "map.addcontrol " needs to be a capital C. If you check the error console in any decent browser, e.g. Firefox, you would see this error flagged up.

              Comment

              • mmect
                New Member
                • Mar 2007
                • 6

                #8
                Originally posted by acoder
                The first problem is line 17 in your code. Compare it to line 16. The "c" in "map.addcontrol " needs to be a capital C. If you check the error console in any decent browser, e.g. Firefox, you would see this error flagged up.
                Thanks for spotting that...i fixed that code. The rounded corners are still not working, however. I can't figure out why. If you look at www.taxxman.com , you can see the rounded corners on the page...go back and forth between contact and home and you'll see the difference. I just can't pinpoint why this happens.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by mmect
                  Thanks for spotting that...i fixed that code. The rounded corners are still not working, however. I can't figure out why. If you look at www.taxxman.com , you can see the rounded corners on the page...go back and forth between contact and home and you'll see the difference. I just can't pinpoint why this happens.
                  Are you sure you've fixed it? On the contacts page, the error still shows up.

                  You have a window.onload for the rounded corner script and body onload for the Google Map script. Either put the load() function into window.onload or the window.onload into load().

                  Comment

                  • mmect
                    New Member
                    • Mar 2007
                    • 6

                    #10
                    Originally posted by acoder
                    Are you sure you've fixed it? On the contacts page, the error still shows up.

                    You have a window.onload for the rounded corner script and body onload for the Google Map script. Either put the load() function into window.onload or the window.onload into load().
                    I updated the Google map code...that works now. Yes, the rounded corner problem still exists. Thanks for the advice, i'll give that a shot and see if it works.

                    Thanks!

                    Comment

                    Working...