javascript - Chrome extension-Open the captured screen shot in new tab -
javascript - Chrome extension-Open the captured screen shot in new tab -
chrome.tabs.query({ active: true, currentwindow: true }, function (tabs) { chrome.tabs.capturevisibletab(null ,{ format: "png"}, function (src) { $('body').append("<img src='" + src + "'>" + tabs[0].url + "</img>");//appends captured image popup.html } ); });
this code appends captured image body of popup.html. want insted of appending image popup body open new tab using chrome.tabs.create({url:"newtab.html") , append captured image newtab.html.(the 'newtab.html' in path folder).
thanks in advance
javascript jquery google-chrome google-chrome-extension share|improve question asked oct 7 '14 @ 6:32 abhilash 390314 add comment | 1 reply 1 active oldest votes up vote 2 down vote acceptedthere way described previosuly here.
the gist open tab contains script, , communicate using messaging.
a little problem arises don't know when newly-opened page ready. solved making newly-opened page contact background page on own, sloppy having 1 global variable.
a improve solution one-shot event listener, that:
// execute code background page, not popup! function openscreenshot(src){ chrome.tabs.create( { url: chrome.runtime.geturl("newtab.html") }, function(tab) { chrome.runtime.onmessage.addlistener(function(message, sender, sendresponse) { // if request expected , comes tab opened if(message.getscreenshot && sender.tab.id == tab.id) { sendresponse(src); // ensure we're run 1 time chrome.runtime.onmessage.removelistener(arguments.callee); } }); } ); }
other that, follow linked answer.
share|improve answer answered oct 7 '14 @ 10:20 xan 29.2k73252 add comment | your answer stackexchange.ifusing("editor", function () { stackexchange.using("externaleditor", function () { stackexchange.using("snippets", function () { stackexchange.snippets.init(); }); }); }, "code-snippets"); stackexchange.ready(function() { inittagrenderer("".split(" "), "".split(" ")); stackexchange.using("externaleditor", function() { // have fire editor after snippets, if snippets enabled if (stackexchange.options.snippets.enabled) { stackexchange.using("snippets", function() { createeditor(); }); } else { createeditor(); } }); function createeditor() { prepareeditor({ heartbeattype: 'answer', convertimagestolinks: true, reputationtopostimages: 10, bindnavprevention: true, postfix: "", ondemand: true, discardselector: ".discard-answer" ,immediatelyshowmarkdownhelp:true }); } }); draft saved draft discarded sign or log in stackexchange.ready(function () { stackexchange.helpers.onclickdraftsave('#login-link'); });sign using google
sign using facebook
sign using email , password
post guest name email stackexchange.ready( function () { stackexchange.openid.initpostlogin('.new-post-login', 'http%3a%2f%2fstackoverflow.com%2fquestions%2f26229882%2fchrome-extension-open-the-captured-screen-shot-in-new-tab%23new-answer', 'question_page'); } ); post guest name email discardposting answer, agree privacy policy , terms of service.
not reply you're looking for? browse other questions tagged javascript jquery google-chrome google-chrome-extension or ask own question.asked
1 year ago
viewed
273 times
active
1 year ago
blog 2016 stack overflow developer survey results var ados = ados || {}; ados.run = ados.run || []; ados.run.push(function () { ados_add_placement(22,8277,"adzerk1274110421",[5,17,2221]).setzone(45); }); ;"use strict";var _extends=object.assign||function(n){for(var i,r,t=1;t0&&(n.tags=i.join(";"))),n}function k(n){return n.innerhtml.replace(/\s+$/g,"")}function st(n,t,i,u){var c=r(n);if(c===null)return function(){};var h=null,e=null,l=f(),a=function a(){k(c)?(s(h),u(!1,f()-l)):e=o(a,t)};return e=o(a,t),i&&(h=o(function(){s(e);u(!0,f()-l)},i)),function(){s(e);s(h)}}function ht(){var t="careers1",i="careers3",u=e.hash.indexof("large=1")!==-1||!g()||r("#careersadsdoublehigh"),f=u?1:2,n=[f+"=hireme"];return r("#"+t)&&n.push("5="+t),r("#"+i)&&n.push("6="+i),n.join("&")}function d(n,i){var r=ot(_extends({},nt,{zones:ht()})),u,e;n&&(r.azt=1);i&&(r.lw=i);typeof t.innerwidth=="number"&&(r.bw=t.innerwidth);u=["zones","ip","ac","eng","prov","tags","theme","at","remote","seed","lw","azt","sysadmin","bw","nocpm","jobview","cpview"];e=l+"?"+ft(r,u);c=f();p(e)}function ct(n){function h(){u.foreach(w);e.foreach(function(n){lt(n,i[n],s,o)});typeof t.clc_after_load=="function"&&t.clc_after_load()}var i=n.cr,r=n.h,u=n.st,e=object.keys(i),o=c?f()-c:0,s="//"+r+"/ct";h()}function lt(n,t,i,f){var h=t.cl,c=t.cn,o=t.an,l=t.utm,s=(h||[]).join(" "),e=r("#"+n);e&&(s&&(e.classname+=" "+s),e.innerhtml=c.replace("&pt=0","&pt="+(f||0)),e.onmousedown=function(n){for(var t=n.target,r,f,s;t.tagname!=="a"&&t!==e;)t=t.parentnode;t!==e&&(r=[],o&&r.push("an="+o),f=[].filter.call(t.attributes,function(n){return/^data-/.test(n.name)}),f.length>0&&f.foreach(function(n){var t=n.name.replace(/^data-/,"");r.push(u(t)+"="+u(n.value))}),r.push("utm="+u(rt+l)),s="",r.length>0&&(s="?"+r.join("&")),t.href=i+s)})}function g(){return y(h).length>0}function at(n){var t=i.createelement("a");return t.href=n,t.host}function vt(){var t,n;g()?(n=st(h,20,t,d),o(function(){var u=r(h),t;k(u)||(u.parentnode.removechild(u),typeof n=="function"&&n(),t=i.createelement("img"),t.src="//"+at(l)+"/to.gif",t.style.display="none",i.body.appendchild(t))},2e3)):d()}var l=n.u,a=n.o,nt=a===undefined?{}:a,t=window,e=t.location,u=t.encodeuricomponent,v=t.decodeuricomponent,i=t.document,tt=i.body,it=i.getelementsbytagname("head")[0],o=t.settimeout,s=t.cleartimeout,rt="&utm_source="+e.hostname+"&utm_medium=ad&utm_campaign=",h="#sidebar [id^=adzerk].everyonelovesstackoverflow",c=0;t.clc={init:ct,load:vt,ls:p,as:w,tags:b}}).call(null, {"u":"//clc.stackoverflow.com/p.js"});"use strict";var allowedhosts=["stackoverflow.com","serverfault.com"];(allowedhosts[0]==="*"||allowedhosts.indexof(location.hostname)!==-1)&&window.clc.load(); linked 0 matching content script lastly keyword match related 866 open url in new tab (and not new window) using javascript 10 communication between background page , popup page in chrome extension 3 chrome extension: create new tab(chrome.tabs.create) , executescript in new tab…not working :( 0 chrome extension: open tabs delay 0 chrome tab.create , capture screenshot of new created tab 0 chrome extension: capture url of newest tab opened 0 opening popup in new tab 0 trigger chrome extension on new tab open 2 chrome extension: capture request url before (or without) opening new tab 1 sending messages devtools panel new tab in chrome extensions hot network questions electrical usage contribute fuel consumption? english language language have grammatical gender? workaround horrible thesis title on academic cv ok independent feedback before handing in thesis? word person learned in past, downwards beginner level? bad seo utilize go on reading toggle? extract min , max values related datetime values on postgres 9+ how patch "keyless entry" auto keys? what's point of ca? name “having no concern truthfulness of one’s own remarks” how cut down size of initrd when compiling kernel? steenrod operations in etale cohomology? ring set? why did rowling seemingly create lite of house-elf situation? earth-based microwave radiometer moon why might paper published in journal no longer available anywhere? there numerical method/built-in calculate boundary of set of graphs? string value of id returns more id age should 1 heed "but i'm not cold!"? odd electrolytic capacitor markings evil doc doozit time extent can keen mind feat replace wizard's spellbook? riddle de do, riddle de dum sort list , maintain particular element @ end of list after sorting more hot questions
Comments
Post a Comment