I have an iframe in my webpage that includes the Draggabilly library and I want to find a way to use it from the parent frame by changing the scope. How do I do this?  In the JavaScript console, I'd just use the cd() function like this:  var iframe = document.querySelector("iframe"); var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; cd(iframe); var draggie = new Draggabilly(".draggable");   This code worked fine in the console but when executed through the actual webpage, it gives me this error: ReferenceError: Draggabilly is not defined  Iframe code:  &lt;script src="https://unpkg.com/draggabilly@2/dist/draggabilly.pkgd.min.js"&gt;&lt;/script&gt;   Parent code:  &lt;script&gt;     var iframe = document.querySelector("iframe");     var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;     cd(iframe);     var draggie = new Draggabilly(".draggable"); &lt;/script&gt;
7175
Basically, I have an iframe embedded in a page and the iframe has some  routines I need to invoke from the parent page.  Now the opposite is quite simple as you only need to call parent.functionName(), but unfortunately, I need exactly the opposite of that.  Please note that my problem is not changing the source  of the iframe, but invoking a function defined in the iframe.
94779
I'm trying to set up an exclusion filter with a browser cookie, so that my own visits to my don't show up in my Google Analytics.  I tried 3 different methods and none of them have worked so far.  I would like help understanding what I am doing wrong and how I can fix this.  Method 1 First, I tried following Google's instructions, , for excluding traffic by Cookie Content:     Create a new page on your domain,   containing the following code:      &lt;body onLoad="javascript:pageTracker._setVar('test_value');"&gt;    Method 2 Next, when that didn't work, I googled around and found this Google thread, , where the most popular answer says to use a slightly different code:       SHS Analytics wrote:         &lt;body onLoad="javascript:_gaq.push(['_setVar','test_value']);"&gt;       Thank you! This has now set a __utmv cookie containing "test_value",   whereas the original:         pageTracker._setVar('test_value')       (which Google is still recommending)   did not manage to do that for me (in   Mac Safari 5 and Firefox 3.6.8).   So I tried this code, but it didn't work for me.    Method 3 Finally, I searched StackOverflow and came across this thread, , which suggests that the following code might work:   &lt;script type="text/javascript"&gt;     var _gaq = _gaq || [];     _gaq.push(['_setVar', 'exclude_me']);     _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);     _gaq.push(['_trackPageview']);  // etc...  &lt;/script&gt;   This script appeared in the head element in the example, instead of in the onload event of the body like in the previous 2 examples.  So I tried this too, but still had no luck with trying to exclude myself from Google Analytics.  Re-iterate question So, I tried all 3 methods above with no success.  Am I doing something wrong?  How can I exclude myself from my Google Analytics using an exclusion cookie for my browser?   Update I've been testing this for several days now, and I've confirmed that the 2nd method of excluding yourself from tracking does indeed work. The problem was that the filter settings weren't properly applied to my profile, which has been corrected.  See the accepted answer below.
14050
I am working on an iGoogle-like application. Content from other applications (on other domains) is shown using iframes.   How do I resize the iframes to fit the height of the iframes' content?  I've tried to decipher the javascript Google uses but it's obfuscated, and searching the web has been fruitless so far.  Update: Please note that content is loaded from other domains, so the  applies.
104708
I'm working on a web page where I'm making an AJAX call that returns a chunk of HTML like:   &lt;div&gt;   &lt;!-- some html --&gt;   &lt;script type="text/javascript"&gt;     /** some javascript */   &lt;/script&gt; &lt;/div&gt;   I'm inserting the whole thing into the DOM, but the JavaScript isn't being run.  Is there a way to run it?    Some details: I can't control what's in the script block (so I can't change it to a function that could be called), I just need the whole block to be executed.  I can't call eval on the response because the JavaScript is within a larger block of HTML.  I could do some kind of regex to separate out the JavaScript and then call eval on it, but that's pretty yucky.  Anyone know a better way?
102457
I have this body of code written for an object that needs to be an obstacle and another object that is draggable.  I have colliders on both and a kinematic rigidbody on the draggable object, but the obstacle is still allowing the dragged object to be dragged through it.  This is all 2d.  I'm not sure what I'm doing wrong.  The part that I'm confused on is this - when you just add a collider to the obstacle sprite and a collider and rigidbody (all 2d) to the draggable sprite, if I don't add the script above, then the draggable sprite falls due to gravity on top of the obstacle and stop there, it doesn't fall through the obstacle sprite.  However when I add the above script which has the OnMouseDrag function, and I move the draggable sprite around because now I can, it falls through the sprite.  With no script the obstacle acts like an obstacle.  With this script the it does not.  using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems;  public class Block : MonoBehaviour {     public GameObject Four_Object1;     //public GameObject clone_Four_Object1;     //private Vector3 screenPoint;     //private Vector3 offset;     private Rigidbody2D rb2d;     private Vector3 screenPoint;     private Vector3 offset;     private Vector3 cursorPosition;      public void Start()     {         rb2d = GetComponent&lt;Rigidbody2D&gt;();         GetComponent&lt;Rigidbody2D&gt;().isKinematic = true;     }      public void OnMouseDown()     {         screenPoint = Camera.main.WorldToScreenPoint(Four_Object1.transform.position);          offset = Four_Object1.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));     }      public void OnMouseDrag()     {          Vector3 cursorScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);         cursorPosition = Camera.main.ScreenToWorldPoint(cursorScreenPoint) + offset;         transform.position = cursorPosition;     }      public void FixedUpdate()     {         rb2d.MovePosition(cursorPosition);         Debug.Log("Update!");     }  }
2972
So i've been working on a Page Object Model framework for a large web application for our current company. It's the first time i've made my own framework and implemented the page object model. Im using Ruby w/Capybara and Selenium-Webdriver for my language/driver of choice.  Currently i've divided each page (or obvious "section of the site") into a class file. This class file has methods for just about everything (or an API of sorts). The problem i've ran into is that I am literally writing a method for every single thing....and i've came across 2 ways people seem to do this:  Lets pretend for a section/page of the site is a widget creation form, the widget has a name/description and some sort of "type" dropdown. Also a save button to save the widget.  Option A (Which is what i've done so far): Make a method for each element (the save button, called save_widget, all the different inputs, etc...)  Option B: Have getter and setter methods for each element, then a larger method which uses these private getter and setter methods.   With Option A my test scripts end up being longer, and honestly not much different than using selenium calls themselves.   Option B would probably call one method (Such as create_widget which would pass in multiple items which that method would call all the smaller getter/setter methods). This would make the test script MUCH shorter and more abstracted. However the getter/setter methods would probably take more actual writing for the page objects themselves (but possibly easier to maintain).  Is there a certain style that favors one over the other? The more I think about it the more Option B seems better...but I wonder if in this case abstraction is a good thing.
118297
I am try to casting idataset to ifeaturelayer i did not get any idea  here my code              ESRI.ArcGIS.ArcMapUI.IMxDocument mxd = ArcMap.Application.Document as                                                    ESRI.ArcGIS.ArcMapUI.IMxDocument;             ESRI.ArcGIS.Carto.IMap map = mxd.FocusMap;             ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wsf = new                          ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactory();             ESRI.ArcGIS.Geodatabase.IWorkspace ws = wsf.OpenFromFile(@"D:\ARC OBJECTS\TemplateData.gdb", ArcMap.Application.hWnd);             ESRI.ArcGIS.Geodatabase.IFeatureWorkspace fws = ws as ESRI.ArcGIS.Geodatabase.IFeatureWorkspace;             ESRI.ArcGIS.Geodatabase.IFeatureDataset fd = fws.OpenFeatureDataset("World");
65201
I am trying to implement cascading so I have loaded two files.  &lt;script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js"&gt;&lt;/script&gt;   But I am getting the error as     Uncaught TypeError: Cannot read property 'SPCascadeDropdowns' of   undefined   in below code  $(document).ready(function() {   $().SPServices.SPCascadeDropdowns({     relationshipList: "Teams%20List",     relationshipListParentColumn: "Team_x0020_Name",     relationshipListChildColumn: "Team_x0020_Member_x0020_Name",      parentColumn: "Team",     childColumn: "Subsystem_x0020_Owner",     debug: true   });   });
24680
This is my first question on here so I hope I'm not breaking any rules, but I have a problem:  I have a site that uses an Adobe Site Catalyst for its online analytics. The suite supports tagging through JavaScript and when implemented, it looks something like this that is placed on http://www.mydomain.com:  &lt;script language="JavaScript" type="text/javascript"&gt; s.channel="/my-tracking-tag/" &lt;/script&gt;`   The problem is that Google is reading this JavaScript and interpreting the s.channel string as a relative location on my website and is crawling it. I then get a 404 error in Google Webmaster Tools saying that the URL http://www.mydomain.com/my-tracking-tag/ does not exist, and that it was linked to by the URL that the JavaScript tag code was on.  Is there any to avoid this behavior? I thought about adding URL with a 404 error to my robots.txt file but tracking campaigns are constantly updating and it would be burdensome to update the text file with the constantly updating tags. I also though about structuring the string in s.channel as something like 's.channel= "/" + "my-tracking-tag" + "/" but I'm not sure if that would due the trick, and would also require implementation guidelines to be developed for the future.
106563
I am trying to use streaming API feature of salesforce, and be able to subscribe to the topic in an external client which is HTML based.  My code is below:  &lt;html&gt;     &lt;head&gt;         &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jsforce/1.9.1/jsforce-core.js"&gt;&lt;/script&gt;         &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jsforce/1.9.1/jsforce-api-streaming.min.js"&gt;&lt;/script&gt;          &lt;script&gt;         function myFunction() {         var jsforce = require('jsforce');         var username = 'XXXXX';         var password = 'YYYYY';         var securityToken = 'ZZZZZ';         const conn = new jsforce.Connection({loginUrl : 'https://test.salesforce.com'});         conn.login(username, password + securityToken, function(err, res) {           if (err) {                return console.error(err);           }         console.log('Authenticated');          conn.streaming.topic("PushTopicUpdates").subscribe(function(message) {             console.log('Event Type : ' + message.event.type);             console.log('Event Created : ' + message.event.createdDate);             console.log('Object Id : ' + message.sobject.Id);             console.log('Event : ' + JSON.stringify(message));           });         });         }         &lt;/script&gt;     &lt;/head&gt;     &lt;body onload="myFunction()"&gt;     &lt;/body&gt; &lt;/html&gt;   I am getting an error as below:     Uncaught ReferenceError: require is not defined       at myFunction (StreamingAPI.html:8)       at onload (StreamingAPI.html:31)
107826
I have a custom block containing a text field and an image field. I would like to render the block so that the image's URL can be defined as a data attribute of the block's wrapper div so that it can be used by a javascript function to create a parallax background effect behind the text field.  If I make a template file block.parallax.html.twig, I am able to render the image HTML.  {{ content.field_parallax_image.0 }}   However If I try to get the actual image URL, nothing is returned  {{ content.field_parallax_image.0['#url'] }}   If I dump the #item keys  {{ dump(content.field_parallax_image.0['#item']|keys) }}   I am able to get target_id, alt, title, width and height values, but I can't find the URL defined anywhere.  I have also tried to see if I could find anything useful in the block preprocess function but the field_parallax_image #url field in the variables is also empty  function mytheme_preprocess_block(&amp;$variables) {     if( isset($variables['content']['body']['#bundle']) &amp;&amp; $variables['content']['body']['#bundle'] == 'parallax'){         $variables['img_url'] = $variables['elements']['content']['field_parallax_image'][0]['#url'];     } }   Is there a way I can get this URL?
122561
Most sources of documentation state that one can declare a webpage a duplicate of another by applying this tag on the duplicate page:  &lt;link rel="canonical" href="(absolute URL to original page)"&gt;   I could generate the above tag via the script below:  &lt;script&gt; var l=document.createElement('Link'); l.rel='canonical';l.href='(absolute URL to original page)'; document.getElementsByTagName('head')[0].appendChild(l); &lt;/script&gt;   My question is, would google be able to process this javascript and believe I'm declaring the page as a duplicate page? or would I be forced to use the link tag in the header?  I ask because I'm trying to reduce the unnecessary bytes required to be processed before the actual user readable content begins.
23772
How do you post data to an iframe?
60984
If you want to use global functions and variable dynamically you can use:  window[functionName](window[varName]);   Is it possible to do the same thing for variables in the local scope?  This code works correctly but currently uses eval and I'm trying to think of how else to do it.  var test = function(){     //this = window     var a, b, c; //private variables      var prop = function(name, def){         //this = window         eval(name+ ' = ' + (def.toSource() || undefined) + ';');              return function(value){             //this = test object             if ( !value) {                 return eval('(' + name + ')');             }             eval(name + ' = value;')             return this;         };      };      return {         a:prop('a', 1),         b:prop('b', 2),         c:prop('c', 3),         d:function(){             //to show that they are accessible via to methods             return [a,b,c];         }     }; }();  &gt;&gt;&gt;test Object &gt;&gt;&gt;test.prop undefined &gt;&gt;&gt;test.a function() &gt;&gt;&gt;test.a() 1 //returns the default &gt;&gt;&gt;test.a(123) Object //returns the object &gt;&gt;&gt;test.a() 123 //returns the changed private variable &gt;&gt;&gt;test.d() [123,2,3]
107640
I have a parent component name "ParentComp" which has 3 attributes A,B and C of type String. I have a nested component "ChildComponent". I want to change the value of parent component's attribute B from child's java script controller.     How can i do that?
121438
I am using jQuery library in my visual force page, but I've faced a major problem when I tried to use tabs "apex:tabPanel".  &lt;script src="{!$Resource.jQuery}"&gt;&lt;/script&gt; &lt;!-- If I delete this script the tabs work !! --&gt;  &lt;apex:tabPanel tabClass="activeTab" inactiveTabClass="inactiveTab"&gt;   &lt;apex:tab label="Tab#1" id="tab1"&gt;&lt;/apex:tab&gt;   &lt;apex:tab label="Tab#2" id="tab2"&gt;&lt;/apex:tab&gt; &lt;/apex:tabPanel&gt;   I get a "JS" errors in the console when I try to click on any tab, but if I delete jQuery library it works. So I guess there is a conflict between jQuery and apex:tabPanel functionality.    Here's what I got in the console   Uncaught ReferenceError: initViewstateTab is not defined  Uncaught TypeError: Object [object Object] has no method 'dispatchEvent'  Uncaught ReferenceError: initViewstateTab is not defined  event.returnValue is deprecated. Please use the standard event.preventDefault() instead. Uncaught TypeError: Object [object Object] has no method 'hasClassName'  Uncaught TypeError: Cannot call method 'replace' of undefined
33339
I used the following code.  libraries.yml      my_module.admin:   version: VERSION   js:     js/my-module.js: {}   dependencies:     - core/jquery     - core/drupal     - core/drupalSettings   my_module.module   /**  * Implements hook_page_attachments().  */ function my_module_page_attachments_alter(array &amp;$attachments) {  $attachments['#attached']['library'][] = 'js/my_module';   // $attachments['#attached']['library'][] = array('my_module', 'admin'); }   my_module/js/my_module.js  (function($, Drupal, drupalSettings) {     Drupal.behaviors.my_module = {       attach: function(context, settings) {         $(document).ready(function() {             alert("hello");             console.log('Loaded');           }         };       })(jQuery, Drupal, drupalSettings);   I have tried many other changes, but the JavaScript file is not used.  I have ported Drupal 7 code that implements hook_boot() and includes that JavaScript file, to Drupal 8.