|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
using loadsubscriptWhat I'm really trying to do is load jquery into an existing page, and
then load my own code, so I can prototype/demo some improvements to a website I can't otherwise modify. interactive("jquery-test", "load and run a jquery file", function(I) { subscript_loader.loadSubScript("file://" + "/usr/share/javascript/jquery/jquery.js", I.buffer.document); subscript_loader.loadSubScript("file://" + "/tmp/test.js", I.buffer.document); }); This definitely loads and runs jquery.js and test.js; if I put alert() calls in test.js they fire, but $() references in test.js fail with "ReferenceError: $ is not defined." Actually, now that I look more closely jquery isn't just logging stylistic warnings, it's also reporting Console error: [JavaScript Warning: "reference to undefined property jQuery.cache[id][name]" {file: "chrome://conkeror-modules/content/rc.js -> file:///home/eichin/.emacs.js -> file:///usr/share/javascript/jquery/jquery.js" line: 679}] Category: component javascript Any suggestions? Is I.buffer.document not the right target object? -- _Mark_ <eichin@...> <eichin@...> _______________________________________________ Conkeror mailing list Conkeror@... https://www.mozdev.org/mailman/listinfo/conkeror |
|
|
Re: using loadsubscriptOn Sat, Oct 03, 2009 at 05:11:01PM -0400, Mark Eichin wrote:
> What I'm really trying to do is load jquery into an existing page, and > then load my own code, so I can prototype/demo some improvements to a > website I can't otherwise modify. > > interactive("jquery-test", > "load and run a jquery file", > function(I) { > subscript_loader.loadSubScript("file://" + > "/usr/share/javascript/jquery/jquery.js", I.buffer.document); > subscript_loader.loadSubScript("file://" + "/tmp/test.js", I.buffer.document); > }); > > This definitely loads and runs jquery.js and test.js; if I put alert() > calls in test.js they fire, but $() references in test.js fail with > "ReferenceError: $ is not defined." Actually, now that I look more > closely jquery isn't just logging stylistic warnings, it's also > reporting > Console error: [JavaScript Warning: "reference to undefined property > jQuery.cache[id][name]" > {file: "chrome://conkeror-modules/content/rc.js -> > file:///home/eichin/.emacs.js -> > file:///usr/share/javascript/jquery/jquery.js" > line: 679}] > Category: component javascript > > Any suggestions? Is I.buffer.document not the right target object? The method that I'm familiar with involves using the DOM to add html:script elements to the document's head to load your js files. -- John Foerch _______________________________________________ Conkeror mailing list Conkeror@... https://www.mozdev.org/mailman/listinfo/conkeror |
|
|
Re: using loadsubscriptOh, that makes more sense. Don't even need to do anything special to
make it activate - just M-x jquery-here RET $("h1").css("backgroundColor", "blue"); RET and the headings turn blue :-) function jquery_this_doc(d, js_code) { var script_el = d.createElementNS(XHTML_NS, "script"); script_el.setAttribute("language", "javascript"); script_el.setAttribute("type", "text/javascript"); script_el.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"); d.body.appendChild(script_el); script_el = d.createElementNS(XHTML_NS, "script"); script_el.textContent = js_code; d.body.appendChild(script_el); } interactive("jquery-here", "load jquery.js into this page, then your command", function(I) { jquery_this_doc(I.buffer.document, (yield I.minibuffer.read($prompt = "jq: ", $history = "jquery-here"))); }); _______________________________________________ Conkeror mailing list Conkeror@... https://www.mozdev.org/mailman/listinfo/conkeror |
|
|
Re: using loadsubscriptOn Sun, Oct 04, 2009 at 01:31:51AM -0400, Mark Eichin wrote:
> Oh, that makes more sense. Don't even need to do anything special to > make it activate - just M-x jquery-here RET > $("h1").css("backgroundColor", "blue"); RET and the headings turn blue > :-) > > function jquery_this_doc(d, js_code) { > var script_el = d.createElementNS(XHTML_NS, "script"); > script_el.setAttribute("language", "javascript"); > script_el.setAttribute("type", "text/javascript"); > script_el.setAttribute("src", > "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"); > d.body.appendChild(script_el); > script_el = d.createElementNS(XHTML_NS, "script"); > script_el.textContent = js_code; > d.body.appendChild(script_el); > } > > interactive("jquery-here", > "load jquery.js into this page, then your command", > function(I) { > jquery_this_doc(I.buffer.document, (yield I.minibuffer.read($prompt > = "jq: ", $history = "jquery-here"))); > }); So it works now? Cool.. maybe put it on the wiki. Maybe a new page about doing web development with conkeror. -- John Foerch _______________________________________________ Conkeror mailing list Conkeror@... https://www.mozdev.org/mailman/listinfo/conkeror |
| Free embeddable forum powered by Nabble | Forum Help |