JavaScript - Google Analytics Code In Safari?
anyone else have issues with their code messing up their page view-ability in Safari on a Mac?
thanks! Similar TutorialsI have the google analytics code but it is presenting itself as not valid. Code: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-xxxxxx-x"); pageTracker._trackPageview(); } catch(err) {} </script> Can anyone help? ALso is this script suitable to link to externally? Hi, Can anyone help define the difference between the 2 scripts below and help identify what is/should happen for each? Code: <script type="text/javascript"> var _gaq = _gaq || []; //NHG COMMENT: if there is an existing account, then it needs to be incorporated within this tag. //The xx-xxxx-x par represents the google account code that needs to be inserted // if there is no existing tag in place, then take out the 2 follwoing lines marked (1) and (2)and (3) (1) _gaq.push(['_setAccount', 'XX-XXXXXX-X']); (2) _gaq.push(['_setDomainName', 'MYSUBDOMAIN.domain.com']); (3) _gaq.push(['_trackPageview']); NHG COMMENT: This is the global tag and everything below this MUST NOT BE CHANGED _gaq.push(['_setAccount', UA-16522538-1']); _gaq.push(['_setDomainName', 'domain.com']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> Code: // copy and paste the tag below <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'XX-XXXXXX-X']); _gaq.push(['_setDomainName', 'MYSUBDOMAIN.domain.com']); _gaq.push(['_trackPageview']); _gaq.push(['_setAccount', UA-16522538-1']); _gaq.push(['_setDomainName', 'domain.com']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> Hi, I have just set up google analytics on my website but it is showing tracking unknown symbol in the status. Is it just the case of it taking time to set up or should it work straight away. Thanks Tyler Hi, i have 1 site with three different brands (three ID numbers). I have made a javascript if-statement but it doesnt work. Somebody see some wrong here, I think it should work properly. Thanks in advance $language and $brand is set... <script type="text/javascript"> var accountId; var url; if($language == 'test') { if($brand = '1') { accountId = 'UA-xxxxx-1' url = '1.com' } else if ($brand = '2') { accountId = 'UA-xxxxx-2' url = '2.com' } else if ($brand = '3') { accountId = 'UA-xxxxx-3' url = '3.com' } var _gaq = _gaq || []; _gaq.push(['_setAccount', accountId]); _gaq.push(['_setDomainName', url]); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview', '/' + window.location.host + '/' + window.location.pathname]); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> Hi from Ireland! I recently signed up to Google Analytics and it began to block my flash content. I removed the tracker code (javascript) and deleted my account though my flash content is still blocked. Can someone help? I'll buy you a pint. Afternoon All, I have managed to secure some JavaScript code from another site that allows me to access values from within my Google Analytics cookie: <!-- begin Referer Check --> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write("<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>" + "</sc" + "ript>"); </script> <script type='text/javascript'> var pageTracker = _gat._getTracker("UA-1-1"); pageTracker._trackPageview(); // // This is a function that I "borrowed" from the urchin.js file. // It parses a string and returns a value. I used it to get // data from the __utmz cookie // function _uGC(l,n,s) { if (!l || l=="" || !n || n=="" || !s || s=="") return "-"; var i,i2,i3,c="-"; i=l.indexOf(n); i3=n.indexOf("=")+1; if (i > -1) { i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; } c=l.substring((i+i3),i2); } return c; } // // Get the __utmz cookie value. This is the cookies that // stores all campaign information. // var z = _uGC(document.cookie, '__utmz=', ';'); // // The cookie has a number of name-value pairs. // Each identifies an aspect of the campaign. // // utmcsr = campaign source // utmcmd = campaign medium // utmctr = campaign term (keyword) // utmcct = campaign content // utmccn = campaign name // utmgclid = unique identifier used when AdWords auto tagging is enabled // // This is very basic code. It separates the campaign-tracking cookie // and populates a variable with each piece of campaign info. // var source = _uGC(z, 'utmcsr=', '|'); var medium = _uGC(z, 'utmcmd=', '|'); var term = _uGC(z, 'utmctr=', '|'); var content = _uGC(z, 'utmcct=', '|'); var campaign = _uGC(z, 'utmccn=', '|'); var gclid = _uGC(z, 'utmgclid=', '|'); // // The gclid is ONLY present when auto tagging has been enabled. // All other variables, except the term variable, will be '(not set)'. // Because the gclid is only present for Google AdWords we can // populate some other variables that would normally // be left blank. // if (gclid !="-") { source = 'google'; medium = 'cpc'; } // Data from the custom segmentation cookie can also be passed // back to your server via a hidden form field var csegment = _uGC(document.cookie, '__utmv=', ';'); if (csegment != '-') { var csegmentex = /[1-9]*?\.(.*)/; csegment = csegment.match(csegmentex); csegment = csegment[1]; } else { csegment = '(not set)'; } // // One more bonus piece of information. // We're going to extract the number of visits that the visitor // has generated. It's also stored in a cookie, the __utma cookis // var a = _uGC(document.cookie, '__utma=', ';'); var aParts = a.split("."); var nVisits = aParts[5]; /* function populateHiddenFields(f) { f.source.value = source; f.medium.value = medium; f.term.value = term; f.content.value = content; f.campaign.value = campaign; f.segment.value = csegment; f.numVisits.value = nVisits; alert('source='+f.source.value); alert('medium='+f.medium.value); alert('term='+f.term.value); alert('content='+f.content.value); alert('campaign='+f.campaign.value); alert('custom segment='+f.segment.value); alert('number of visits='+f.numVisits.value); return false; } */ document.forms["cforms2"].elements["cf2_field_1"].value = source; </script> The key outputs from this code are the vars: source medium term content campaign csegment nVisits My question is, how can I get the source var into the hidden field in the form in my footer http://www.yogaholidays.co? I have tried to pass just the source var from within the <script> tags. document.forms["cforms2"].elements["cf2_field_1"].value = source; I have commented out part of original code that I did not think I needed. Any help that can be offered I would be grateful, ultimately I would like to be able to pass all these values to hidden fields. Thanks Paul Brown I have a google analytics code that I need to put on the website I have done. So my question is can I add this code as an external .js page or would I need to put it on the page itself? As I would rather place it as an external file. Code: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-xxxxxx-x"); pageTracker._trackPageview(); } catch(err) {} </script> Firefox works a dream, but in IE, Google Chrome, Safari and Avant javascript does not run at all. Looking at the code it may be the body 'onload' that is not firing? Has anyone got any advise on this on how I might be able to fix it. the javascript Code: /* Script by FPMC at http://jsarchive.8m.com Submitted to JavaScript Kit (http://javascriptkit.com) For this and 400+ free scripts, visit http://javascriptkit.com */ src = ['../images/Intro_01.png', '../images/Intro_02.png', '../images/Intro_03.png', '../images/Intro_04.png', '../images/Intro_05.png', '../images/Intro_06.png']; //set image paths // url = ['http://freewarejava.com', 'http://javascriptkit.com', 'http://dynamicdrive.com', 'http://www.geocities.com']; //set corresponding urls duration = 3; //set duration for each image //Please do not edit below ads=[]; ct=0; function switchAd() { var n=(ct+1)%src.length; if (ads[n] && (ads[n].complete || ads[n].complete==null)) { document['Intro_Image'].src = ads[ct=n].src; } ads[n=(ct+1)%src.length] = new Image; ads[n].src = src[n]; setTimeout('switchAd()',duration*1000); } the body tag Code: <body onload="switchAd(this);"> the img tag Code: <img id="Intro_Image" src="images/Intro_01.png" alt="slideshow" style="width: 230px; border: 0;"> I had to develop a word game for a class project. The final is revolving around this class project but I was marked down some points for this project. I need to find out what I did wrong so I can pass my Final Exam. The program passed Google Chrome and Safari, but the teacher said it didn't pass Firefox Error Console. Any pointers will help. <html> <head> <title> Project </title> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function GetLetter() // Assumes: There are 5 letters // Results: Returns a single letter { var letter letter = RandomOneOf(['a', 'e', 'l', 'm', 'n']); return letter; } </script> <script type="text/javascript"> function GetWord(lastLetter) // Assumes: There is a letter the user has selected // Results: Returns a four letter word ending with the letter the user has selected { var word lastLetter = document.getElementById('lastLetter').value word = ''; l = 0; while (l < 3) { word = word + GetLetter(); l = l + 1; } return word + lastLetter; } </script> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function CheckWord(word) // Assumes: The user entered a word // Results: Will check to see if the word matched the winning word { var cWord cWord = false; if (word=="lane" || word=="lean" || word=="mama" || word=="meal" || word=="name") { cWord = true; } return cWord } </script> <script type="text/javascript"> function trytowin() // Assumes: The user returned a true or false answer // Results: Will Check to see if the user has won or lost { var word, t = 0; document.getElementById('winningWord').value = ""; document.getElementById('winLoss').value = 'Lose'; document.getElementById('lowords').innerHTML = ''; valid = false; while (t < 20 && valid == false) { word = GetWord(lastLetter); valid = CheckWord(word); document.getElementById('lowords').innerHTML = document.getElementById('lowords').innerHTML + word + '<br>'; t = t + 1; if (valid == true) { document.getElementById('winningWord').value = word; document.getElementById('winLoss').value = 'Won after ' + t + ' times!'; } } } </script> </head> <body> <p> Your word is: <input type="text" id="winningWord" size=10><br> You: <input type="text" id="winLoss" size=20><br> Type in a letter chosen from a,e,l,m,n <input type="text" id="lastLetter" size=2 value=""> Press the button to get a word ending with that letter and see if you won<input type="button" value="Try to Win!" onclick="trytowin();"> <hr> <div id="lowords"></div> </body> </html> So I have made a website that you need a password to get into. The following javascript code works in Internet Explorer but, I need it to work in Safari also. Can anyone please rewrite this code, as simple as possible, to work in both Safari and Internet Explorer ? [CODE ]<!--// function mainpass() { if (pass.value=="password") {location="correct.HTML"}; else{location="wrong.HTML"}; } //--> [/CODE] Thanks in advance... Hi, I need to determine how to fix a Google map script and I cannot figure out how. I'm new to adding Google maps to a web page, so I need help. I searched Google Maps website and still cannot figure it out. I'm under a tight deadline to complete by Monday. Could someone please tell me what code changes I need to make to fix it? I'd really appreciate it. Below are the javascripts and further below is the div tag to display the map. <html> <head> <title>Broken Map</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script src="../js/scriptaculous-js-1.8.1/lib/prototype.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script type="text/javascript"> $("item1").style.backgroundColor="red"; var map; var resultsLayer; function initialize() { var originalcenter = new google.maps.LatLng(37.875696,-95.624207); var myOptions = { zoom: 4, center: originalcenter, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map"), myOptions); resultsLayer = new google.maps.FusionTablesLayer({ suppressInfoWindows: false, query: { from: '1008134', select: 'Location' } }); resultsLayer.setMap(map); } </script> </head> <body> <div id="map"></div> </body> </html> Hi, I'm making a javascript with google maps API. The concept is that you have to fill in your desired location and that it shows you the route to that location. It has an unchangeable starting location. I also made it so that you have a description panel. Now when I try to make it so that the description panel is next to the map with the route on, my description panel just drops below my map. I believe this problem is either me f*cking up my div's or my CSS. Here's what i used for my CSS <style type="text/css"> html, body { height: 100%; margin: 0; padding: 0; } #map_canvas { height: 100%; width: 70% } #directionsPanel { float:right; width:30%; height 100% } @media print { html, body { height: auto; } #map_canvas { height: 650px; } } </style> And here's what i used for my div's <div id="main" style="width:100%;height:100%"> <div id="map_canvas" style="top:30px;width:70%;height:80%"></div> <div id="warnings_panel" style="width:100%;height:10%;text-align:center"></div> <div id="directionsPanel" style="float:right;width:30%;height 100%"></div> </div> Any help regarding this would be much appreciated. (And yes, I'm still new to scriptwriting/coding in general) this code works in google chrome, but not in firefox. Code: function merge(obj1, obj2) { var a ={}; for (var p in obj1) { try { // Property in destination object set; update its value. if ( obj1[p].constructor==Object ) { a[p] = merge(a[p], obj1[p]); } else { a[p] = obj1[p]; } } catch(e) { // Property in destination object not set; create it and set its value. a[p] = obj1[p]; } } for (var p in obj2) { try { // Property in destination object set; update its value. if ( obj2[p].constructor==Object ) { a[p] = merge(a[p], obj2[p]); } else { a[p] = obj2[p]; } } catch(e) { // Property in destination object not set; create it and set its value. a[p] = obj2[p]; } } return a; } var d=function(){'c';} var a ={a:{b:'c'},b:'c'} var b ={c:a,d:d}; var c = merge(window,b); WHY?!?!?!?!?!?!?!?!?!?!?!?!??!?!?!?! Hello chaps, I'm Nick I'm in the process of creating a web app using Google Maps. What the following code should do is retrieve some xml code from a page, then load it on to the map, using the geocoder to get lat/long values from the address. Most of it's just Google code I've mauled about with. The map loads, but none of the markers load on to the map. I've gone to the php page which generates the XML for the markers and all is fine there. I know the code is a messy crock of junk, I was sort of concentrating on trying to make it work then I'll sort out the nomenclature. Bad methodology, I know. Code: var id = null; var adress = null; var image = null; var point = null; var pointer = null; var geocoder = null; var iconBlue = new GIcon(); iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(52.2725, -0.8825), 12); geocoder = new GClientGeocoder(); GDownloadUrl("phpsqlajax_genxml3.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { id = markers[i].getAttribute("ID"); address = markers[i].getAttribute("ADDRESS"); image = markers[i].getAttribute("IMAGE"); var point3 = showAddress(address); var marker = createMarker(pointer, id, address, image); map.addOverlay(marker); } }); } } function showAddress(address) { point = geocoder.getLatLng(address,function(point) { if (!point) { alert(address + " not found"); } else { pointer = new GLatLng(point); return pointer; } }); } function createMarker(pointer, id, address, image) { var marker4 = new GMarker(pointer); var html = "<b>" + id + "</b> <br/>" + address + "</b> <br/>" + image; GEvent.addListener(marker, 'click', function() { marker4.openInfoWindowHtml(html); }); return marker4; } Thanks in advance I have put this together and it looks to me like it should work but when i ht submit it does nothing, no error or anything, which makes it hard for me to diagnose. You all are much more experienced minds and may look at it and see my error right away (at least thats what im hoping) the point of this project is a form that will post(including pics) to a google spreadsheet. it may be i need to post this in the ajax forum, but its at least partially js so let me know thank you so much for your help all Code: <!DOCTYPE html> <html> <head> <title>QC Observation</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> </head> <body> <div> <form id="form" target="_self" onsubmit="" action=""> <div class="ss-header-image-container"><div class="ss-header-image-image"><div class="ss-header-image-sizer"></div></div></div> <div class="ss-top-of-page"><div class="ss-form-heading"><h1 class="ss-form-title" dir="ltr">QC Observation</h1> <div class="ss-form"><form action="https://docs.google.com/forms/d/1jkIpSFH16SiNlsj13cBBRsuoiXmqeGVAI6PttCQiff8/formResponse" method="POST" id="ss-form" target="_self" onsubmit=""><ol role="list" class="ss-question-list" style="padding-left: 0"> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1344879795"><div class="ss-q-title">Bldg <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.1344879795" id="entry_1344879795" aria-label="Bldg " aria-required="true" required=""><option value=""></option> <option value="A Residence">A Residence</option> <option value="B Residence">B Residence</option> <option value="C Residence">C Residence</option> <option value="D Residence">D Residence</option> <option value="OSB">OSB</option> <option value="MNT">MNT</option> <option value="TWB">TWB</option> <option value="VP">VP</option> <option value="VM">VM</option> <option value="Site Dev">Site Dev</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1358292836"><div class="ss-q-title">QC Representative <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.1358292836" id="entry_1358292836" aria-label="QC Representative " aria-required="true" required=""><option value=""></option> <option value="David Bradley">David Bradley</option> <option value="Ryan Harper">Ryan Harper</option> <option value="Herschell Mirick">Herschell Mirick</option> <option value="Bill Bejelis">Bill Bejelis</option> <option value="Nick Pappas">Nick Pappas</option> <option value="Stephen Gehrlich">Stephen Gehrlich</option> <option value="Beth Davis">Beth Davis</option> <option value="Ohene Akrofi">Ohene Akrofi</option> <option value="Mike Dow">Mike Dow</option> <option value="David Picknell">David Picknell</option> <option value="Lynne Viescas">Lynne Viescas</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_895392494"><div class="ss-q-title">Shop Responsible <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.895392494" id="entry_895392494" aria-label="Shop Responsible " aria-required="true" required=""><option value=""></option> <option value="Walls/Ceilings">Walls/Ceilings</option> <option value="Plumbing">Plumbing</option> <option value="Electrical">Electrical</option> <option value="HVAC/Sheet Metal">HVAC/Sheet Metal</option> <option value="Carpentry">Carpentry</option> <option value="Interiors">Interiors</option> <option value="Exteriors">Exteriors</option> <option value="Masonry">Masonry</option> <option value="Mechanics">Mechanics</option> <option value="Structural">Structural</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-select"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1493538421"><div class="ss-q-title">Issue Type </div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <select name="entry.1493538421" id="entry_1493538421" aria-label="Issue Type "><option value=""></option> <option value="Poor Workmanship">Poor Workmanship</option> <option value="Lack of Training">Lack of Training</option> <option value="Not Per Plans">Not Per Plans</option> <option value="Not Per Code">Not Per Code</option> <option value="Not Per Spec">Not Per Spec</option> <option value="Plan Conflict">Plan Conflict</option></select> <div class="required-message">This is a required question</div></div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-paragraph-text"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_177485091"><div class="ss-q-title">Notes/Actions </div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <textarea name="entry.177485091" rows="8" cols="0" class="ss-q-long" id="entry_177485091" dir="auto" aria-label="Notes/Actions "></textarea> <div class="error-message" id="754075454_errorMessage"></div> <div class="required-message">This is a required question</div> </div></div></div> <div class="ss-form-question errorbox-good" role="listitem"> <div dir="ltr" class="ss-item ss-item-required ss-date"><div class="ss-form-entry"> <label class="ss-q-item-label" for="entry_1875356531"><div class="ss-q-title">Follow-Up Date <label for="itemView.getDomIdToLabel()" aria-label="(Required field)"></label> <span class="ss-required-asterisk" aria-hidden="true">*</span></div> <div class="ss-q-help ss-secondary-text" dir="ltr"></div></label> <input type="date" name="entry.1875356531" value="" class="ss-q-date" dir="auto" id="entry_1875356531" aria-label="Follow-Up Date " aria-required="true" required=""> <div class="required-message">This is a required question</div></div></div></div> <input type="hidden" name="draftResponse" value="[,,"3618330731406970920"] "> <input type="hidden" name="pageHistory" value="0"> <input type="hidden" name="fbzx" value="3618330731406970920"> <tr> <td>Image File</td> <td> <input type="file" name="uploadedFile" class="gwt-FileUpload"> </td> </ol></div> <div style="width: 100%; display: block; float: right;"> <button id="send" type="submit"> Send </button> </div> </form> </div> <script type="text/javascript"> function postToGoogle() { var field1 = $("input[type='radio'][name='qs1']:checked").val(); var field2 = $("input[type='radio'][name='qs2']:checked").val(); var field3 = $('#feed').val(); $.ajax({ url: "https://docs.google.com/forms/d/1jkIpSFH16SiNlsj13cBBRsuoiXmqeGVAI6PttCQiff8/formResponse", data: {"entry.1023121230": field3, "entry.1230072460": field1, "entry.2113237615": field2}, type: "POST", dataType: "xml", statusCode: { 0: function() { //Success message }, 200: function() { //Success Message } } }); } $(document).ready(function(){ $('#form').submit(function() { postToGoogle(); return false; }); }); </script> </body> </html> Reply With Quote 01-27-2015, 10:10 AM #2 Dormilich View Profile View Forum Posts Senior Coder Join Date Jan 2010 Location Behind the Wall Posts 3,532 Thanks 13 Thanked 372 Times in 368 Posts first you should verify whether your AJAX actually sends something off: open the browser’s dev tools and check the network panel for any outgoing requests. I might as well mention the SOP (same origin policy) here that governs which URLs you are allowed to contact. I'm new to the forum. So hi everyone. The code below works fine on IE and FF but not on Google Chrome. Can someone tell me where I'm doing wrong? Thank you for your answers in advance. Im really looking forward much to hearing from you. You can preview the below code by pasting it to Frontpage, Dreamweaver and etc. Quote: <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/JavaScript"> <!-- function show(id) { if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = ''; } } //--> <!-- function hide(id) { document.getElementById(id).style.display = 'none'; } //--> </script> </head> <body> <div> <div> <table cellspacing="1" cols="3" border="0"> <tbody> <td><a onfocus="hide('tblB');hide('tblC');show('tblA');" href="#">A</a> <td><a onfocus="hide('tblA');hide('tblC');show('tblB');" href="#">B</a> <td><a onfocus="hide('tblB');hide('tblA');show('tblC');" href="#">C</a> </td> </tr> </tbody> </table> </div> <div> <table id="tblA" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select A, table tblA is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblB" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select B, table tblB is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblC" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select C, table tblC is shown </td> </tr> </tbody> </table> </div> </div> </body> </html> I have a page with a GoogleMap with a GoogleBar and I would like the GoogleBar to appear with something written in it already and to have that search executed. In other words, I would like to "write something to the GoogleBar and press Enter" automatically as soon as the map loads. How can I do this? btw: By GoogleBar, I mean the search bar that appears on the map after using the enableGoogleBar() function. First of all, I read the rules regarding how to post a question on the forums, and I couldn't think of a much better description, so I hope thats okay. My problem is this, I am using a simple code (Posted Below) that creates a drop-down menu containing a list of languages, when any of these languages are clicked it sends the user to Google translate to automatically convert the text. The code works fine, but now Im realizing I have no way of knowing which languages are chosen and how often. I have tried linking it to my Google Analytics but to no avail. The only solution I can think of is to send the user to maybe a PHP file that then redirects them to the Google translate page, so I can monitor it by viewing how many times the redirect page was viewed. I already use this redirect technique to track how many users follow my links to external downloads, so I know its probable. But my real question is how would I go about sending the user to a redirect page? I'm a novice web developer by the way. I'm thinking I would have to send the variable containing language to the redirect, along with a variable containing the URL to be translated, and then have the redirect input the data same as the original form. But even if this is possible, I don't know how to go about it. Any help would be greatly appreciated. Quote: <select name="translate" style="height:18px; font-size:10px;" onchange="javascript:window.location = 'http://www.google.com/translate_c?hl=en&langpair=en%7C' + this.value + '&u=' + window.location.href;"> <option value="">Translate This Page</option> <option value="ar">Arabic</option> ...LIST OF OTHER LANGUAGES <option value="es">Spanish</option> </select> Hi, I'm not sure where I have translated this incorrectly. I have one google map embedded on my page which works fine. But I wanted to add a second one. I thought the easiest way to do this would be to have a second page which is called later on with all the details on it for the second map. However although I think (this I presume is where I went wrong) I have replicated the instructions correctly the place holder for the second map just remains blank. This is the code for my called page with the instructions for the second map: PHP Code: <?php echo $_POST['Map'] . '<br />'; ?> <div id="placemap_canvas"></div> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #placemap_canvas {width:100%; height:150px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM regions WHERE RegionPId='{$_POST['Map']}'"); while($row = mysql_fetch_array($result)){ echo $row['maplink']; } mysql_close($con); ?> ); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("placemap_canvas"), myOptions); } </script> And this is the script of the main page, just in case I would be better off keeping them both in one place. Code: <head> <script type="text/javascript"> function loadSubPlace(File,ID,Msg,Eile,EID,Esg){ loadXMLDoc1(File,ID,Msg); var mimer = setTimeout(function(){loadXMLDoc1(Eile,EID,Esg)},5000); } </script> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #map_canvas {width:30%; height:250px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM countries WHERE Country='{$_SESSION['Country']}'"); while($row = mysql_fetch_array($result)){ echo $row['Map']; } mysql_close($con); ?>); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> </head> <body onload="initialize()"> <div class="countryright" id="map_canvas"> include("dbconnect.php"); $snowball=explode(';',$_POST['syringa']); $turnsol=$snowball[1]; $violet =$snowball[2]; $wakerobin=$snowball[3]; global $turnsol; global $violet; global $wakerobin; echo '<center><b><big>' . $wakerobin. '</big></b></center><br /><br />'; $result=mysql_query("SELECT * FROM regions WHERE country='{$turnsol}' AND region='{$violet}' AND place='{$wakerobin}' AND sub !='' ORDER BY sub ASC"); while($row = mysql_fetch_array($result)){ $wheat="{$row['RegionPId']};{$turnsol};{$violet};{$wakerobin};{$row['sub']}"; $tigerlilly=$row['RegionPId']; echo '<input type="button" class="button3" name="place" id="place" value="' . $row['sub'] . '" onclick="loadSubPlace(\'getPlace.php\',\'txtHintPlaceSub\',\'hepatica=' . urlencode($wheat) . '\',\'getPlaceMap.php\',\'placemapcanvas\',\'Map=' . urlencode($tigerlilly) . '\');" />'; } echo '<input type="button" class="button3" name="addplace" id="addplace" value="Add Place" onclick="loadXMLDoc1(\'getAddPlaceSub.php\',\'txtHintPlaceSub\', encodeURI(\'addsubplace=' . $_POST['syringa'] . '\'));" />'; echo '<br /><br /><div id="txtHintPlaceSub"></div><br /><br />'; mysql_close($con); ?> I've cut out the script that doesn't relate to this so I hope I haven't missed anything important. Can the Google API replace scraping? You can get blocked by Google if you scrape, but can you get the same info from the Google API at no risk?
|