Talk:Code snippets: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
TrashF (talk | contribs)
No edit summary
Zvn (talk | contribs)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== jQuery problems? ==
== jQuery problems? ==
Anyone else getting only "$ is not defined" when trying the example jQuery script? The other (older) method works, though. --[[User:TrashF|TrashF]] 13:20, 24 May 2009 (EDT)
Anyone else getting only "$ is not defined" when trying the example jQuery script? The other (older) method works, though. --[[User:TrashF|TrashF]] 13:20, 24 May 2009 (EDT)
:Ditto. --[[User:Zvn|Zvn]] 16:36, 5 December 2009 (UTC)


== July 8 2007 ==
== July 8 2007 ==
Line 44: Line 45:


How can I use this script and how does it work?
How can I use this script and how does it work?
:[[Greasemonkey_Manual#Interactive_Support |Greasemonkey Manual &rarr; Interactive Support]]<br /><small> [[User:Marti|Marti]] 13:52, 24 May 2009 (EDT)</small>

Latest revision as of 16:36, 5 December 2009

jQuery problems?

Anyone else getting only "$ is not defined" when trying the example jQuery script? The other (older) method works, though. --TrashF 13:20, 24 May 2009 (EDT)

Ditto. --Zvn 16:36, 5 December 2009 (UTC)

July 8 2007

Edit undone. 146.151.111.140, it looks like you deleted about 3 quarters of the page, so i undid your change. This does mean that you will have to make the intended changes again...

Restructure?

This page is rather messy. Does anyone have ideas for how to better structure this information? --Henrik 05:48, 5 June 2007 (EDT)

It is getting a bit big, perhaps separating it out into different pages, each with a short explanation, the code and some examples. The main page would just have the links and a one line description. Also some more logical categories could help. --Alien scum 18:43, 6 June 2007 (EDT)

array.forEach in XPath example

Re: http://wiki.greasespot.net/index.php?title=Code_Snippets&diff=prev&oldid=1784

Restored that example, it works fine (using Fx 2) without Prototype. See e.g. http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach.

Just try it:

 // ==UserScript==
 // @name          Example
 // @namespace     wiki
 // @include       *
 // ==/UserScript==
 
 function $x(p, context) {
   if (!context) context = document;
   var i, arr = [], xpr = document.evaluate(p, context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
   for (i = 0; item = xpr.snapshotItem(i); i++) arr.push(item);
   return arr;
 }
 
 var i, paragraphs = $x("//p");	 
 paragraphs.forEach(function(paragraph) { // Loop over every paragraph	 
 	paragraph.innerHTML = "Halloa!";	 
 });

--81.225.78.185 18:18, 25 March 2007 (EDT)


Make script accessible to Firebug

How can I use this script and how does it work?

Greasemonkey Manual → Interactive Support
Marti 13:52, 24 May 2009 (EDT)